aws/amazon-cloudwatch-agent

Static append_dimensions value on prem results in no metrics being published

risqbenp opened this issue · 3 comments

Describe the bug
When append_dimensions is configured, ec2tagger is added as a processor, even if the append_dimensions values are static.
This results in metrics not being sent to cloudwatch on premise without access to IDMS.

Steps to reproduce
Configure a static key value pair in metrics append_dimensions, run cloudwatch agent without access to IDMS.

What did you expect to see?
Metrics should be published to cloudwatch agent with the appropriate statically configured dimensions.

What did you see instead?
A clear and concise description of what you saw instead.
No metrics were published to AWS Cloudwatch

What version did you use?
Version: 1.300042.1b746

What config did you use?
Config:

{"agent": {"metrics_collection_interval": 60, "region": "eu-west-1", "run_as_user": "cwagent"}, "metrics": {"metrics_collected": {"cpu": {"measurement": ["cpu_usage_idle"], "totalcpu": true}, "disk": {"ignore_file_system_types": ["sysfs", "tmpfs", "devtmpfs", "vfat", "squashfs", "loop", "efivarfs"], "measurement": ["used_percent"], "resources": ["*"]}, "mem": {"measurement": ["used_percent"]}, "net": {"interface": ["eno1np0", "ens5"], "measurement": ["bytes_sent", "bytes_recv", "packets_sent", "packets_recv"]}, "swap": {"measurement": ["used_percent"]}}, "append_dimensions": {"InstanceId": "mi-redacted"}}}

Environment
OS: Ubuntu 22.04

Formatted your config to be a bit easier to read.

{
  "agent": {
    "metrics_collection_interval": 60,
    "region": "eu-west-1",
    "run_as_user": "cwagent"
  },
  "metrics": {
    "metrics_collected": {
      "cpu": {
        "measurement": [
          "cpu_usage_idle"
        ],
        "totalcpu": true
      },
      "disk": {
        "ignore_file_system_types": [
          "sysfs",
          "tmpfs",
          "devtmpfs",
          "vfat",
          "squashfs",
          "loop",
          "efivarfs"
        ],
        "measurement": [
          "used_percent"
        ],
        "resources": [
          "*"
        ]
      },
      "mem": {
        "measurement": [
          "used_percent"
        ]
      },
      "net": {
        "interface": [
          "eno1np0",
          "ens5"
        ],
        "measurement": [
          "bytes_sent",
          "bytes_recv",
          "packets_sent",
          "packets_recv"
        ]
      },
      "swap": {
        "measurement": [
          "used_percent"
        ]
      }
    },
    "append_dimensions": {
      "InstanceId": "mi-redacted"
    }
  }
}

The top-level metrics::append_dimensions does not currently support arbitrary key-value pairs as mentioned in the documentation (https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-Agent-Configuration-File-Details.html).

(trimmed down to relevant parts)

The only supported key-value pairs for append_dimensions are shown in the following list. Any other key-value pairs are ignored. The agent supports these key-value pairs exactly as they are shown in the following list. You can't change the key values to publish different dimension names for them.

  • "InstanceId":"${aws:InstanceId}" sets the instance's instance ID as the value of the InstanceId dimension.

If you want to append dimensions to metrics with arbitrary key-value pairs, use the append_dimensions parameter in the field for that particular type of metric.

If you want to have a non-IMDS provided InstanceId dimension, it must be added to each of the plugins.

{
  "metrics": {
    "metrics_collected": {
      "cpu": {
        "measurement": [
          "cpu_usage_idle"
        ],
        "totalcpu": true,
        "append_dimensions": {
          "InstanceId": "mi-redacted"
        }
      }
   }
}

Hello!
Is your issue resolved?

Yes thanks, all good!