Open carlbergman opened 3 years ago
I'll need to look into this a bit further. Any specific reason you want to hardcode the LogStream name? This can have scalability issues since a single LogStream is limited to 5 MB/s. Can you confirm the environment variables are available in your application process (e.g. console.log(process.env)
)? Are you calling setDimensions
on your logger or putDimensions
?
Relevant tests:
Thanks for the reply!
Any specific reason you want to hardcode the LogStream name? This can have scalability issues since a single LogStream is limited to 5 MB/s.
I wanted to make the log stream name similar to the log streams for the app (app/app/ecsTaskId
) and agent (agent/agent/ecsTaskId
) instead of the default name (arn_aws_ecs_eu-north-1_redactedAccountId_task/redactedClusterName/ecsTaskid
).
That's when I found out that neither Configuration.logStreamName
or AWS_EMF_LOG_STREAM_NAME
had any effect. I was unaware of the scalability issues and will have to make a new decision regarding the name, but it would still be interesting to learn the proper way to set the log stream name.
Can you confirm the environment variables are available in your application process (e.g.
console.log(process.env)
)?
I can confirm that the correct environment variables are logged when the application starts.
Are you calling
setDimensions
on your logger orputDimensions
?
Thanks for pointing this out. I used setDimensions
instead of putDimensions
. By changing it to putDimensions
the service name and service type are correctly added to the logged metric. Sorry for not realizing this before raising an issue. The problem with the log stream name still remains, though.
but it would still be interesting to learn the proper way to set the log stream name
100% agree. I need to spend some time on this.
Sorry for not realizing this before raising an issue
No worries! Appreciate you opening the issue. I understand the confusion and open to hearing any suggestions as to how we can improve.
Yes, just looking at using this library in a lambda and finding that three dimensions are added by default.
"Dimensions": [
[
"LogGroup",
"ServiceName",
"ServiceType"
]
],
The LogGroup and ServiceName were long random gibberish in each account I was using so I tried to change them but found that AWS_EMF_LOG_GROUP_NAME
didn't seem to have any effect. I looked in the repo and it's not actually used anywhere I could find (except the test). AWS_EMF_SERVICE_NAME
works though.
Update: The work around for me was to simply replace the default dimension set with a custom one and avoid trying to set the Log Group at all.
metricsLogger.setNamespace('FooBar');
metricsLogger.setDimensions({
ServiceName: 'FooBar',
});
I would still like to know how it can be set.
Problems
Config
These are the container definitions:
This is the agent config:
This is what the agent sidecar logs:
This is what the app container logs:
However, the metric gets logged to another log stream (not the one in AWS_EMF_LOG_STREAM_NAME) and it does not include the AWS_EMF_SERVICE_TYPE or AWS_EMF_SERVICE_NAME.