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

Allow use of Instance Tags in the configuration file

Open kixorz opened this issue 2 years ago • 10 comments

Description of the issue

Hello, I've had the same problem like the author of this issue. I'd like to use an instance tag to create a log group in the agent configuration to construct and display an environment name based on a tag value.

Thank you for considering this change. If any are changes needed, please provide any suggestions on how to improve the solution.

Description of changes

The change fetches a list of instance tags from EC2 instance metadata, stores it locally and uses the list to translate the tag placeholders in the configuration file.

License

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Tests

I've successfully tested the solution on an EC2 instance with Enabled instance tags with a custom tag.

Steps:

  1. Add tags of your choice to your instance, for example use TestTag and assign a TestValue
  2. Use tags in the cloudwatch-agent config.json, for example use "log_stream_name": "{instance_id}_{tag:TestTag}"
  3. Enable instance metadata tags on the instance. See announcement and documentation
  4. Observe the translation of {tag:TestTag} to TestValue in amazon-cloudwatch-agent.log

kixorz avatar May 05 '23 11:05 kixorz

Hello @sethAmazon - What can I do to possibly move this forward?

kixorz avatar May 08 '23 14:05 kixorz

One outstanding question I have is if this also covers AWS reserved tags. It would be really awesome if this contribution also covered the use case in #738

SaxyPandaBear avatar May 15 '23 15:05 SaxyPandaBear

I have confirmed through testing that with this change (and Instance Tags enabled) an autoscaling group propagating aws:ec2launchtemplate:id or other tags can be referenced in the config by {tag:aws:ec2launchtemplate:id} and are correctly translated to the tag value.

kixorz avatar May 16 '23 03:05 kixorz

Are we good on this one?

kixorz avatar May 23 '23 14:05 kixorz

@kixorz apologies, I haven't heard from our product team yet on this. I'll try to follow up. From a technical standpoint, it looks good to me.

SaxyPandaBear avatar May 23 '23 15:05 SaxyPandaBear

This PR was marked stale due to lack of activity.

github-actions[bot] avatar May 31 '23 00:05 github-actions[bot]

@SaxyPandaBear @kixorz can we put eyes and effort to get this through? Would be a nice feature to have.

nickgalantowicz avatar Dec 08 '23 20:12 nickgalantowicz

Seems like the team doesn't want to move this forward. Maybe some communication clarity around this would help?

kixorz avatar Dec 16 '23 13:12 kixorz

@SaxyPandaBear @nathalapooja @adam-mateen @mitali-salvi Can we get insights on the teams thoughts with this pr? Hoping to at least get some clarity on why or why not this is progressing.

nickgalantowicz avatar Dec 20 '23 17:12 nickgalantowicz

This PR was marked stale due to lack of activity.

github-actions[bot] avatar Aug 18 '24 00:08 github-actions[bot]