我正在尝试使用以下CloudFormation模板基于异常检测模型创建警报并收到错误:
有人可以帮我吗?
"Resources": {
"CPUUtilizationAlarm": {
"Type": "AWS::CloudWatch::Alarm",
"Properties": {
"AlarmDescription": "Alarm Triggered",
"AlarmName": "CPUUtilizationAlarm",
"ComparisonOperator": "GreaterThanUpperThreshold",
"EvaluationPeriods": 1,
"Dimensions": [],
"Metrics": [
{
"Expression": "ANOMALY_DETECTION_BAND(m1, 10)",
"Id": "ad1"
},
{
"Id": "m1",
"MetricStat": {
"Metric": {
"MetricName": "CPUUtilization",
"Namespace": "AWS/EC2",
"Dimensions": [
{
"value": "i-05157fe1be36d52bd",
"name": "InstanceId"
}
],
},
"Period": 60,
"Stat": "Average"
}
}
],
"ThresholdMetricId": "ad1",
"TreatMissingData": "breaching",
}
}
}
答案 0 :(得分:3)
对于每个错误,警报定义中都有一个名为name
的属性,该属性无效。仔细观察,Dimensions数组具有键name
和value
,而应分别为Name
和Value
,而不是此处定义的示例中的
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cw-dimension.html。
答案 1 :(得分:1)
正如另一个答案所指出的那样,一些属性被错误地大写。 The CloudFormation Linter可以通过以下有用的错误消息来帮助您捕获此类错误:
open System.Collections.Concurrent
let _MessageQueue = ConcurrentQueue<string>()
let messages = ResizeArray<string>()
let mutable continueLooping = true
while continueLooping do
let success, message = _MessageQueue.TryDequeue()
messages.Add(message)
continueLooping <- success
E3003 Property Name missing at Resources/CPUUtilizationAlarm/Properties/Metrics/1/MetricStat/Metric/Dimensions/0
so.json:22:25
E3003 Property Value missing at Resources/CPUUtilizationAlarm/Properties/Metrics/1/MetricStat/Metric/Dimensions/0
so.json:22:25
E3002 Invalid Property Resources/CPUUtilizationAlarm/Properties/Metrics/1/MetricStat/Metric/Dimensions/0/value
so.json:23:27
E3002 Invalid Property Resources/CPUUtilizationAlarm/Properties/Metrics/1/MetricStat/Metric/Dimensions/0/name
so.json:24:27