Closed Lykr closed 1 year ago
I ran into the same error on v5.0.0.
The root cause seems to be because of this code line: https://github.com/cdklabs/cdk-monitoring-constructs/blob/0d79e94c89dba85e5532a355717c199000505fec/lib/common/metric/AnomalyDetectionMathExpression.ts#L42.
All math expresion will have ReturnData
to be true
, while the CDK only expect one of them to be true
and the others should be false
per this doc: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cloudwatch-alarm-metricdataquery.html#cfn-cloudwatch-alarm-metricdataquery-returndata.
I just logged a similar bug https://github.com/cdklabs/cdk-monitoring-constructs/issues/425. Should have checked issues before cutting one but anyway.
I don't think ReturnData
is the problem here, I was able to create an anomaly detection on a normal metric, despite ReturnData
is true
on both the expression and the metric, CFN and CW didn't complain. Though, I agree that when there are multiple expressions, only one should be marked as true.
"Properties": {
"Metrics": [
{
"Expression": "ANOMALY_DETECTION_BAND(alarm_a20137860f588,3)",
"Id": "expr_1",
"Label": "Band (stdev 3)",
"ReturnData": true
},
{
"Id": "alarm_a20137860f588",
"ReturnData": true,
...Other props omitted
}
],
"ThresholdMetricId": "expr_1",
"TreatMissingData": "breaching"
}
Version
v3.0.0
Steps and/or minimal code example to reproduce
.monitorCustom()
function to monitor a custom metric.Expected behavior
Deploy successfully.
Actual behavior
Failed to deploy.
Other details
No response