Search code examples
autoscalingaws-ecs

ECS Auto Scaling - Unable to scale out on CPU Reservation metric


I have the below Auto Scaling Policy which should add instance when the CPU reservation goes beyond 75%. I am not seeing any Alarm triggered for this setup

Policy type:
Simple scaling
Execute policy when:
ECS-CPUHighAlarm
breaches the alarm threshold: CPUReservation > 75 for 5 consecutive periods 
of 60 seconds for the metric dimensions AutoScalingGroupName = ECS-
ECSAutoScalingGroup
Take the action:
Add 1 instances And then wait: 600 seconds before allowing another scaling 
activity

Below is the CloudFormation Script.

CPUHighAlarm:
Type: 'AWS::CloudWatch::Alarm'
Properties:
  EvaluationPeriods: 5
  Statistic: Average
  Threshold: 75
  AlarmDescription: 'Alarm if CPU reservation is high.'
  Period: 60
  AlarmActions:
  - !Ref 'CPUScalingUpPolicy'
  Namespace: 'AWS/ECS'
  Dimensions:
  - Name: AutoScalingGroupName
    Value: !Ref 'ECSAutoScalingGroup'
  ComparisonOperator: GreaterThanThreshold
  MetricName: CPUReservation

But its not happening based on what I have observed with chart given below. CPU Reservation Chart

Any thoughts on where I am missing the configuration?


Solution

  • I think i found the issue. It was in the CloudFormation Template. When using the namespace as AWS/ECS below are valid dimension,

    Dimensions:
    - Name: ClusterName
      Value: !Ref 'ECSClusterName'
    

    Hence the Alarm was invalid and was stuck as INSUFFICIENT_DATA which I realized only later after reading this,

    https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/ecs-metricscollected.html

    I ran the test and the Alarm is getting triggered and Auto Scaling.