amazon-cloudwatch-agent icon indicating copy to clipboard operation
amazon-cloudwatch-agent copied to clipboard

Change Prometheus "instance" value

Open quaeler opened this issue 2 years ago • 3 comments

Is your feature request related to a problem? Please describe. For a Fargate task, the CW Agent for Prometheus emits instance to be the VPC IP address (plus port) of the container. For forensics investigation (ie. which task instance is this that is complaining?), this is not immediately helpful (through a number of queries, one could wander their way back to the task instance, but not as easily as knowing the task instance already.)

For example from a cwagent-ecs-file-sd-config log entry:

...
"instance": "172.31.14.84:9404"
...

Describe the solution you'd like For the instance value, it would be nice for it to be the task instance id (e.g 7bd02f006a93486ab9bdc77e86c2bd68 - not the Task Definition); if there can exist a 1-N mapping of task instance and container instance, then the instance value would be better as the Container Runtime Id, as opposed to the VPC IP address.

Describe alternatives you've considered Post processing of the IP address can be done, but for the Cloud Watch graph experience lending itself to immediate container drill-down, i am ignorant of a nice pain-free way to do this.

quaeler avatar Apr 29 '22 02:04 quaeler

This issue was marked stale due to lack of activity.

github-actions[bot] avatar Aug 13 '22 00:08 github-actions[bot]

If not change the instance label to be the task ID, could at least have an additional label like TaskId or similar. Then folks could relabel as desired.

benclapp avatar Jun 09 '23 06:06 benclapp

Turns out the TaskId label was already added a wee while ago with PR https://github.com/aws/amazon-cloudwatch-agent/pull/334, I was just using quite an old version 😅

To get the ID as an instance label, could use this relabel config to set it

  - source_labels: [TaskId]
    target_label: instance

benclapp avatar Jun 12 '23 04:06 benclapp