我正在为我的应用程序使用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 上使用请求计数警报,将不胜感激。