在AWS中缩小Auto Scaling组会导致永久警报

时间:2016-02-20 17:41:40

标签: amazon-web-services autoscaling amazon-cloudwatch

我目前正在使用两个附加到我的自动缩放组的扩展策略: 甲

  1. 调用CloudWatch警报时调用的向上扩展策略。此CloudWatch警报使用CPUUtilization指标,并在CPU上触发超过80%。
  2. 另一种是缩小策略,在调用其他CloudWatch警报时调用该策略。此CloudWatch警报使用CPUUtilization指标,并在CPU低于50%时触发。
  3. 这种方法的副作用是当我的ASG实例空闲(完全按比例缩小,没有发生处理)时,我的ASG处于警报状态。

    有没有办法以不同的方式设置它,以便我的ASG不会处于持续警报状态?

    以下是我的CloudFormation模板中的一部分警报:

    "ScaleUpPolicy" : {
      "Type" : "AWS::AutoScaling::ScalingPolicy",
      "Properties" : {
        "AdjustmentType" : "ChangeInCapacity",
        "AutoScalingGroupName" : { "Ref" : "WebApplicationASG" },
        "Cooldown" : "1",
        "ScalingAdjustment" : "1"
      }
    },
    "CPUAlarmHigh": {
      "Type": "AWS::CloudWatch::Alarm",
      "Properties": {
        "EvaluationPeriods": "1",
        "Statistic": "Average",
        "Threshold": "80",
        "AlarmDescription": "Alarm if CPU too high or metric disappears indicating instance is down",
        "Period": "60",
        "AlarmActions": [ { "Ref": "ScaleUpPolicy" } ],
        "Namespace": "AWS/EC2",
        "Dimensions": [ {
          "Name": "AutoScalingGroupName",
          "Value": { "Ref": "WebApplicationASG" }
        } ],
        "ComparisonOperator": "GreaterThanThreshold",
        "MetricName": "CPUUtilization"
      }
    },
    "ScaleDownPolicy" : {
      "Type" : "AWS::AutoScaling::ScalingPolicy",
      "Properties" : {
        "AdjustmentType" : "ChangeInCapacity",
        "AutoScalingGroupName" : { "Ref" : "WebApplicationASG" },
        "Cooldown" : "1",
        "ScalingAdjustment" : "-1"
      }
    },
    "CPUAlarmLow": {
      "Type": "AWS::CloudWatch::Alarm",
      "Properties": {
        "EvaluationPeriods": "1",
        "Statistic": "Average",
        "Threshold": "50",
        "AlarmDescription": "Alarm if CPU is low, causing scale down",
        "Period": "60",
        "AlarmActions": [ { "Ref": "ScaleDownPolicy" } ],
        "Namespace": "AWS/EC2",
        "Dimensions": [ {
          "Name": "AutoScalingGroupName",
          "Value": { "Ref": "WebApplicationASG" }
        } ],
        "ComparisonOperator": "LessThanThreshold",
        "MetricName": "CPUUtilization"
      }
    },
    

2 个答案:

答案 0 :(得分:4)

这是正常和预期的行为。

在警报状态下使用指标不是问题 - 请记住,触发事件的是警报状态的更改。因此,大概一旦你的放大触发器进入警报状态,缩小比例就会出现警报。然后,当度量标准下降时,它将返回到警报状态,并触发缩小事件。

答案 1 :(得分:0)

您可以通过单击“隐藏自动缩放警报”复选框在控制台中隐藏这些内容。

https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/hide-autoscaling-alarms.html

仍然不理想,但总比没有好。