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?

6
  • Isn't the ASG tagged with the ECS cluster name ? (or it's name derived)
    – Tensibai
    Jul 3, 2017 at 8:31
  • Not necessarily, the only thing that actually couples the ASG to ECS is the configuration file for ecs-agent located on each instance. Jul 3, 2017 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 3, 2017 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. Jul 3, 2017 at 14:22
  • I just followed the AWS console wizard to create a sample cluster to test out of curiosity :)
    – Tensibai
    Jul 3, 2017 at 14:42

2 Answers 2

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'
1
  • Provided this is sent from the same instance as the service is running at. What about an external script that needs to figure out this information? Nov 1, 2017 at 9:24
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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.