7

我正在为我的应用程序使用AWS CloudFormation ,并尝试通过相应的模板发出请求计数警报。我可以成功地直接为Elastic Load Balancer发出请求计数警报,但是当我尝试通过 CloudFormation 模板实现相同功能时,Amazon CloudWatch中的警报状态是“数据不足”。

我的 ELB JSON 是:

"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"
    }
  }
},

我的警报 JSON 是:

"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"
        }
      }
    ]
  }
},

从上面它会生成以“数据不足”为状态的警报。谁能告诉我可能是什么原因?如果有任何示例/示例模板可用于在 ELB 上使用请求计数警报,将不胜感激。

4

1 回答 1

7

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.
于 2012-04-07T21:33:39.400 回答