Amazon-Web-Services

Cloudformation ELB Cloudwatch 警報 InsufficientData

  • January 4, 2017

我使用 cloudformation 為我的服務設置了一堆 cloudwatch 警報。除了 ELB 警報,我所有的警報都有效。他們總是只顯示不足的數據。我可以進入控制台並手動設置警報,但我希望能夠使用 cloudformation 模板來創建所有內容。我的 json 中的某個地方一定有一個錯誤來發出警報。這是其中之一:

"ELBHighLatencyAlarm": {
   "Type": "AWS::CloudWatch::Alarm",
   "Properties": {
       "Namespace": "AWS/ELB",
       "AlarmName": { "Fn::Join" : ["", [ { "Ref" : "AWS::StackName"}, "-ELB-ELBHighLatencyAlarm"]]},
       "AlarmDescription":  { "Fn::Join" : ["", [ { "Ref" : "AWS::StackName"}, "-ELB-ELBHighLatencyAlarm"]]},
       "ComparisonOperator": "GreaterThanThreshold",
       "Threshold": "0.5",
       "EvaluationPeriods": "1",
       "Period": "300",
       "MetricName": "Latency",
       "Statistic": "Average",
       "OKActions": [],
       "AlarmActions": [ { "Ref": "PagerDutySNSTopicArn" } ],
       "InsufficientDataActions": [ { "Ref": "PagerDutySNSTopicArn" } ],
       "Dimensions": [ {
           "Name": "ElasticLoadBalancer",
           "Value": { "Ref": "WebServerLoadBalancer" }
       }]
   }
}

你看有什麼不對嗎?

您的"Dimensions"部分未使用正確的"Name"值。如果您更換:

"Dimensions": [ {
           "Name": "ElasticLoadBalancer",
           "Value": { "Ref": "WebServerLoadBalancer" }
       }]

"Dimensions": [ {
           "Name": "LoadBalancerName",
           "Value": { "Ref": "WebServerLoadBalancer" }
       }]

你應該會發現你的鬧鐘會起作用。

我可以確認Dojo上面所說的。儘管維度塊描述中的措辭看起來好像不是必需的,並且字元串/值是任意的,但是有一個特定的名稱列表可用於您要為其創建警報的每種類型的服務。此列表將服務類型映射到維度塊中的允許值,從而使您的警報正常工作。

在我看來,維度塊是過濾事件的一種方式。因此,如果您想查看集群的 CPUUtilization,您將提供 ClusterName。如果您想要集群的特定服務,您可以向維度塊提供 2 個條目。集群名稱和服務名稱。

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

下面兩個範例之間的唯一區別是Dimensions.Name 欄位。

不起作用的範例

"CPUUtilizationScaleInAlarm": {
 "Type": "AWS::CloudWatch::Alarm",
 "Properties": {
   "ActionsEnabled": true,
   "AlarmActions": [
     {
       "Ref": "ESCServiceScaleInPolicy"
     }
   ],
   "AlarmDescription": "Scale in in response to CPUUtilization being low",
   "AlarmName": "CPUUtilizationScaleIn",
   "ComparisonOperator": "LessThanOrEqualToThreshold",
   "Dimensions": [
     {
       "Name": "ECService",
       "Value": "MyAwesomeService"
   ],
   "EvaluationPeriods": 1,
   "MetricName": "CPUUtilization",
   "Namespace": "AWS/ECS",
   "Period": 60,
   "Statistic": "Average",
   "Threshold": 25,
   "Unit": "Percent"
 }
}

起作用的範例

"CPUUtilizationScaleInAlarm": {
 "Type": "AWS::CloudWatch::Alarm",
 "Properties": {
   "ActionsEnabled": true,
   "AlarmActions": [
     {
       "Ref": "ESCServiceScaleInPolicy"
     }
   ],
   "AlarmDescription": "Scale in in response to CPUUtilization being low",
   "AlarmName": "CPUUtilizationScaleIn",
   "ComparisonOperator": "LessThanOrEqualToThreshold",
   "Dimensions": [
     {
       "Name": "ServiceName",
       "Value": "MyAwesomeService"
   ],
   "EvaluationPeriods": 1,
   "MetricName": "CPUUtilization",
   "Namespace": "AWS/ECS",
   "Period": 60,
   "Statistic": "Average",
   "Threshold": 25,
   "Unit": "Percent"
 }
}

引用自:https://serverfault.com/questions/730246