Skip to content

service.name and deployment.environment not being picked up #2120

Description

@davidjmemmett

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

  1. Specify service.name and deployment.environment in /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.json
  2. 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
  3. Restart amazon-cloudwatch-agent.service
  4. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions