1
votes

I am in the INSUFFICENT_DATA state constantly for my scale down cloudwatch alarm. The cloudwatch alarm is attached to my autoscaling group. I have had my scale down alarm be in this state for the past 3 days, so it's definitly done initializing.

In my alarm it gives the reason of

Unchecked: Initial alarm creation

This is from the aws docs: https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/AlarmThatSendsEmail.html

INSUFFICIENT_DATA—The alarm has just started, the metric is not available, or not enough data is available for the metric to determine the alarm state

Here is a snippet from my cloudformation template that makes the cloudwatch alarm. It is in troposphere syntax but it should be easy enough to read:

template.add_resource(Alarm(
    "CPUUtilizationLowAlarm",
    ActionsEnabled=True,
    AlarmDescription="Scale down for average CPUUtilization <= 30%",
    Namespace="AWS/EC2",
    MetricName="CPUUtilization",
    Statistic="Average",
    Period="300",
    EvaluationPeriods="3",
    Threshold="30",
    Unit="Percent",
    ComparisonOperator="LessThanOrEqualToThreshold",
    AlarmActions=[Ref("ScaleDownPolicy")],
    Dimensions=[
        MetricDimension(
            Name="AutoscalingGroupName",
            Value=Ref("AutoScalingGroup")
        )
    ]
))
template.add_resource(ScalingPolicy(
    "ScaleDownPolicy",                                                      #Simple reference value, nothing special
    AdjustmentType="ChangeInCapacity",                                      #Modify the asg capacity
    AutoScalingGroupName=Ref("AutoScalingGroup"),                           #What asg to modify capacity
    PolicyType="SimpleScaling",                                             #Read about it here: https://docs.aws.amazon.com/autoscaling/ec2/userguide/as-scale-based-on-demand.html
    Cooldown="1700",                                                        #How long to wait before checking status' again
    ScalingAdjustment=Ref("DownscalingCount")                               #(Must be a negative number!!) How much to scale down
))

As you can see I am scaling down based on the CPUUtilization <= 30%. This is a valid metric from what I can see. I have read this stack overflow answer but it doesn't seem to apply to this situation: Amazon EC2 AutoScaling CPUUtilization Alarm- INSUFFICIENT DATA

I do almost the exact same thing but use "Step Scaling" instead of "Simple Scaling", like above, but it actually works for me. Here is a snippet from my cloudformation template for my step scaling alarm (Scale up):

template.add_resource(Alarm(
    "CPUUtilizationHighAlarm",
    ActionsEnabled=True,
    AlarmDescription="Scale up for average CPUUtilization >= 50%",
    MetricName="CPUUtilization",
    Namespace="AWS/EC2",
    Statistic="Average",
    Period="300",
    EvaluationPeriods="1",
    Threshold="50",
    Unit="Percent",
    ComparisonOperator="GreaterThanOrEqualToThreshold",
    AlarmActions=[Ref("ScaleUpPolicy")],
    Dimensions=[
        MetricDimension(
            Name="AutoScalingGroupName",
            Value=Ref("AutoScalingGroup")
        )
    ]
))
template.add_resource(ScalingPolicy(
    "ScaleUpPolicy",
    AdjustmentType="ChangeInCapacity",
    AutoScalingGroupName=Ref("AutoScalingGroup"),                           #What group to attach this to
    EstimatedInstanceWarmup="1700",                                         #How long it will take before instance is ready for traffic
    MetricAggregationType="Average",                                        #Breach if average is above threshold
    PolicyType="StepScaling",                                               #Read above step scaling here: https://docs.aws.amazon.com/autoscaling/ec2/userguide/as-scale-based-on-demand.html
    StepAdjustments=[                                                       
        StepAdjustments(
            MetricIntervalLowerBound="0",                                   #From 50 (Defined in alarm as 50% CPU)
            MetricIntervalUpperBound="20",                                  #To 70%
            ScalingAdjustment="1"                                           #Scale up 1 instance
        ),
        StepAdjustments(
            MetricIntervalLowerBound="20",                                  #from 70%
            MetricIntervalUpperBound="40",                                  #to 90%
            ScalingAdjustment="2"                                           #Scale up 2 instances
        ),
        StepAdjustments(
            MetricIntervalLowerBound="40",                                  #From 90% or above (Defined in alarm)
            ScalingAdjustment="3"                                           #Scale up 2 instances
        )
    ]
))

I am at a lost as to what I have configured wrong in my scale down alarm. If anyone has any suggestions or help that would be great.

1
I ran the cli command: "aws cloudwatch list-metrics --namespace=AWS/EC2" and "CPUUtilization" was found in that list. - wesleywh
I tried switching the simple scaling scale down policy to step scaling but it didn't solve anything. It doesn't look like any metrics are getting sent to my alarm either. The preview window for the CPU Utilization shows no activity. - wesleywh

1 Answers

1
votes

I found the problem...

The error was here:

MetricDimension(
        Name="AutoscalingGroupName",
        Value=Ref("AutoScalingGroup")
    )

The Name should be AutoScalingGroupName NOT AutoscalingGroupName. It will try to generate a new dimension and not correctly pull from the autoscaling group. So it will not throw an error and will spin everything up okay it will just have no data to pull from. Therefore will remain in the INSUFFICENT_DATA state until the end of time.

Capital "S"...