1
votes

I am using the CloudWatch agent to create metrics for disk usage, memory usage, cpu, and a couple other things. I would like to aggregate metrics based on the autoscaling group, using "AutoScalingGroupName":"${aws:AutoScalingGroupName}".

However, I'm using Blue/Green deployments with CodeDeploy, which creates a copy of the Autoscaling Group. The alarms I originally made for aggregations on the autoscaling groups are gone, and I can't put a widget in my Dashboard that shows avg cpu, memory, etc.

My quick solution was to use a custom append_dimension that is set to a hardcoded value, and aggregate dimensions on that. Is there an automated way that AWS provides that I don't know about?

1
append_dimensions is the only way I can think as well. Even with other with other metric platforms like InfluxDB/Telegraf, you'd have to specify some custom tag, like service/tier.peter n

1 Answers

0
votes

I don't have experience of the above scenario using AWS console.

But, since I work on Terraform (infrastructure as code) mostly, you can use like this:

dimensions = {
    AutoScalingGroupName = tolist(aws_codedeploy_deployment_group.autoScalingGroup.autoscaling_groups)[0]
  }

Reason for converting it into list - the output of

aws_codedeploy_deployment_group.asg.autoscaling_groups

is a set value, which you can see when you output the value of the codedeployment group autoscaling group - it uses toset function. The metric dimensions for the CloudWatch metric alarm expects a string. So, the conversion of a set type (which is unordered) to list type is needed so that you can access the first element of the autoscaling group - which is the newly created copy of the autoscaling group by codedeploy.