Describe the bug
According to the AWS documentation, the fields service.name and deployment.environment should be customisable in order to be able to distinguish logs from each other (service.name being a project name and deployment.environment being an environment name). This seems to work for a handful of logs, then reverts to the instance's hostname (or instance name tag?) and ec2:default.
Steps to reproduce
- Specify
service.name and deployment.environment in /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.json
- Run
/opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -c file:/opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.json
- Restart
amazon-cloudwatch-agent.service
- Write some logs to a location where AWS CloudWatch Agent is watching.
What did you expect to see?
In AWS CloudWatch Console -> Log Insights, using the query
fields @timestamp, @message,@entity.KeyAttributes.Name, @entity.KeyAttributes.Environment
| sort @timestamp desc
| limit 10000
All log entries should have the custom service.name and deployment.environment.
What did you see instead?
Custom service.name and deployment.environment are added to log entries for ~10 entries, then revert to the instance's hostname (or it's instance name tag) and ec2:default.
What version did you use?
Version 1.300067.0b1404-1
What config did you use?
Config: Custom JSON config file
Environment
OS: Ubuntu 24.04 LTS
Additional context
Ideally we'd be able to send rich, structured logs to AWS CloudWatch with custom attributes, instead only raw syslog is being sent. So we need to be able to distinguish projects/environments from each other.
Describe the bug
According to the AWS documentation, the fields
service.nameanddeployment.environmentshould be customisable in order to be able to distinguish logs from each other (service.namebeing a project name anddeployment.environmentbeing an environment name). This seems to work for a handful of logs, then reverts to the instance's hostname (or instance name tag?) andec2:default.Steps to reproduce
service.nameanddeployment.environmentin/opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.json/opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -c file:/opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.jsonamazon-cloudwatch-agent.serviceWhat did you expect to see?
In AWS CloudWatch Console -> Log Insights, using the query
All log entries should have the custom
service.nameanddeployment.environment.What did you see instead?
Custom
service.nameanddeployment.environmentare added to log entries for ~10 entries, then revert to the instance's hostname (or it's instance name tag) andec2:default.What version did you use?
Version 1.300067.0b1404-1
What config did you use?
Config: Custom JSON config file
Environment
OS: Ubuntu 24.04 LTS
Additional context
Ideally we'd be able to send rich, structured logs to AWS CloudWatch with custom attributes, instead only raw syslog is being sent. So we need to be able to distinguish projects/environments from each other.