Reputation: 1
I want to iterate through a list of ec2 instances, then for each instance add/append certain custom metrics of my choosing to their existing configurations. Problem is I don't know which config files they're using, and how many there can be. I know there's a config.json but there's also could be a file in the cloudwatch.agent.d directory. Are there any other possible config files? And how/which do I append to it? Ideally would like to automate this via ssm.
Upvotes: 0
Views: 28
Reputation: 466
I am using SSM Parameter Store for config management. There, I have one GENERAL config that is used by all EC2 instances. Additionally, I have SPECIFIC config for EC2 instances that require more setting beyond the GENERAL config.
Here is how you could do it:
#fetch GENERAL config from the SSM parameter store:
sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -s -m ec2 -c ssm:AmazonCloudWatch-GENERAL-cw-config
#fetch SPECIFIC config from the SSM parameter store:
sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a append-config -m ec2 -s -c ssm:AmazonCloudWatch-SPECIFIC-cw-config
Upvotes: 0