문제

I am using AWS CloudFormation for my application and am trying to make a request count alarm via a respective template. I can successfully make the request count alarm directly for the Elastic Load Balancer, but the alarm state within Amazon CloudWatch is "insufficient data", when I'm trying to achieve the same via a CloudFormation template.

My ELB JSON is:

"ElasticLoadBalancer": {
  "Type": "AWS::ElasticLoadBalancing::LoadBalancer",
  "Properties": {
    "AvailabilityZones": {
      "Fn::GetAZs": ""
    },
    "Listeners": [
      {
        "LoadBalancerPort": "80",
        "InstancePort": {
          "Ref": "WebServerPort"
        },
        "Protocol": "HTTP"
      }
    ],
    "HealthCheck": {
      "Target": {
        "Fn::Join": [
          "",
          [
            "HTTP:",
            {
              "Ref": "WebServerPort"
            },
            "/"
          ]
        ]
      },
      "HealthyThreshold": "3",
      "UnhealthyThreshold": "5",
      "Interval": "30",
      "Timeout": "5"
    }
  }
},

My alarm JSON is:

"StatisticAlarmLow": {
  "Type": "AWS::CloudWatch::Alarm",
  "Properties": {
    "AlarmDescription": "Alarm if there are too many unhealthy hosts.",
    "MetricName": "RequestCount",
    "Namespace": "AWS/ELB",
    "Statistic": "Sum",
    "Period": "60",
    "EvaluationPeriods": "2",
    "ComparisonOperator": "LessThanThreshold",
    "Threshold": "1500",
    "AlarmActions": [
      {
        "Ref": "WebServerScaleUpPolicy"
      }
    ],
    "Unit": "Count",
    "Dimensions": [
      {
        "Name": "AutoScalingGroupName",
        "Value": {
          "Ref": "WebServerGroup"
        }
      }
    ]
  }
},

"StatisticAlarmHigh": {
  "Type": "AWS::CloudWatch::Alarm",
  "Properties": {
    "AlarmDescription": "Alarm if there are too many unhealthy hosts.",
    "MetricName": "RequestCount",
    "Namespace": "AWS/ELB",
    "Statistic": "Sum",
    "Period": "60",
    "EvaluationPeriods": "2",
    "ComparisonOperator": "GreaterThanThreshold",
    "Threshold": "4000",
    "AlarmActions": [
      {
        "Ref": "WebServerScaleUpPolicy"
      }
    ],
    "Unit": "Count",
    "Dimensions": [
      {
        "Name": "AutoScalingGroupName",
        "Value": {
          "Ref": "WebServerGroup"
        }
      }
    ]
  }
},

From the above it generates the alarm with "insufficient data" as a state. Can anybody tell me what could be the reason? And if there is any sample/example template available for using request count alarm on ELB, it will be appreciated.

도움이 되었습니까?

해결책

The Elastic Load Balancing (ELB) fragment alarm fragment of your Amazon CloudFormation template seems okay, but your Amazon CloudWatch fragment contains a presumably incorrect dimension, insofar it references an AutoScalingGroupName named WebServerGroup - this isn't a supported dimension as per section Dimensions for Elastic Load Balancing Metrics on page Monitoring Your Load Balancer Using CloudWatch, stating Elastic Load Balancing data can be aggregated along any of the following dimensions:

  • LoadBalancerName - Limits the metric data to Amazon EC2 instances that are connected to the specified load balancer.
  • AvailabilityZone - Limits the metric data to load balancers in the specified Availability Zone.
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top