Allow use of Instance Tags in the configuration file
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:
- Add tags of your choice to your instance, for example use
TestTagand assign aTestValue - Use tags in the cloudwatch-agent
config.json, for example use"log_stream_name": "{instance_id}_{tag:TestTag}" - Enable instance metadata tags on the instance. See announcement and documentation
- Observe the translation of
{tag:TestTag}toTestValueinamazon-cloudwatch-agent.log
Hello @sethAmazon - What can I do to possibly move this forward?
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
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.
Are we good on this one?
@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.
This PR was marked stale due to lack of activity.
@SaxyPandaBear @kixorz can we put eyes and effort to get this through? Would be a nice feature to have.
Seems like the team doesn't want to move this forward. Maybe some communication clarity around this would help?
@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.
This PR was marked stale due to lack of activity.