3

We are looking to inspect the ASG EC2 CloudWatch metrics such as CPU and Memory, since it includes an aggregate of all the ASG instances.

Given that we know the ECS cluster, or the ECS service name. Which API calls would be needed to figure out the name of the Auto Scaling Group and its CloudWatch metrics?

Evgeny Zislis
  • 9,023
  • 5
  • 39
  • 72
  • Isn't the ASG tagged with the ECS cluster name ? (or it's name derived) – Tensibai Jul 03 '17 at 08:31
  • Not necessarily, the only thing that actually couples the ASG to ECS is the configuration file for ecs-agent located on each instance. – Evgeny Zislis Jul 03 '17 at 14:03
  • Just done a quick test, but my ASG has a tag aws:cloudformation:stack-name wich is valued with EC2ContainerService-<my-cluster-name>. Did I miss a point ? – Tensibai Jul 03 '17 at 14:10
  • Someone wrote that tag explicitly in your CloudFormation template. A good idea, I'll adopt it. But it's it there by default. – Evgeny Zislis Jul 03 '17 at 14:22
  • I just followed the AWS console wizard to create a sample cluster to test out of curiosity :) – Tensibai Jul 03 '17 at 14:42
  • And as far as I can tell, every cloudformation stack get this aws:cloudformation:stack-name tag automatically. – Tensibai Jul 03 '17 at 14:44

2 Answers2

2

Example in AWS cli that should work to get the ASG name

a=curl 'http://169.254.169.254/latest/meta-data/instance-id'; aws autoscaling describe-auto-scaling-instances --instance-ids $a --query 'AutoScalingInstances[*].AutoScalingGroupName'
Vorsprung
  • 320
  • 3
  • 12
0

Here I ran for ap-south-1 region-

a=curl 'http://169.254.169.254/latest/meta-data/instance-id'c ; aws autoscaling describe-auto-scaling-instances --instance-ids $a --query 'AutoScalingInstances[0].AutoScalingGroupName' --region ap-south-1

Bruce Becker
  • 3,783
  • 4
  • 20
  • 41