-
Notifications
You must be signed in to change notification settings - Fork 4.5k
CloudWatch: Math expression in alarm doesn't respect period #32221
Copy link
Copy link
Open
Labels
@aws-cdk/aws-cloudwatchRelated to Amazon CloudWatchRelated to Amazon CloudWatchbugThis issue is a bug.This issue is a bug.effort/smallSmall work item – less than a day of effortSmall work item – less than a day of effortp2
Description
Describe the bug
I'm defining an alarm as follows:
let latencyImpactAlarm: Alarm = new Alarm(
this,
val + "LatencyImpact",
{
alarmName: val + "-node-high-latency-impact",
actionsEnabled: false,
datapointsToAlarm: 3,
evaluationPeriods: 5,
metric: new MathExpression({
period: Duration.seconds(60),
expression: 'TIME_SERIES(0) + ((INSIGHT_RULE_METRIC("' +
latencyRule.ruleName +
'", "MaxContributorValue") / m1) * 100)',
usingMetrics: {
"m1": new Metric({
namespace: "AWS/ApplicationELB",
metricName: "RequestCount",
dimensionsMap: {
"LoadBalancer": value
},
statistic: "Sum",
period: Duration.seconds(60)
})
}
}),
threshold: .1,
comparisonOperator:
ComparisonOperator.GREATER_THAN_OR_EQUAL_TO_THRESHOLD,
},
);This produces CFN as follows:
"Metrics": [
{
"Expression": "TIME_SERIES(0) + ((INSIGHT_RULE_METRIC(\"HighLatencyRequestsPerNode-app-multi--ALBAE-7sFFT5bABDxM-2fa0f6aeb46f1279\", \"MaxContributorValue\") / m1) * 100)",
"Id": "expr_1"
},
{
"Id": "m1",
"MetricStat": {
"Metric": {
"Dimensions": [
{
"Name": "LoadBalancer",
"Value": "app/multi--ALBAE-7sFFT5bABDxM/2fa0f6aeb46f1279"
}
],
"MetricName": "RequestCount",
"Namespace": "AWS/ApplicationELB"
},
"Period": 60,
"Stat": "Sum"
},
"ReturnData": false
}
],When deployed, this causes an error: Resource handler returned message: "Error in expression 'expr_1': Parameter Query Period is invalid. Please specify a Period.
Even though the period is set, it is not included in the synth'd CFN template. If you add in the period manually, the resource successfully deploys.
{
"Expression": "TIME_SERIES(0) + ((INSIGHT_RULE_METRIC(\"HighLatencyRequestsPerNode-app-multi--ALBAE-7sFFT5bABDxM-2fa0f6aeb46f1279\", \"MaxContributorValue\") / m1) * 100)",
"Id": "expr_1",
"Period": 60
},Regression Issue
- Select this option if this issue appears to be a regression.
Last Known Working CDK Version
No response
Expected Behavior
I expect the period field to be included in the resulting CFN.
Current Behavior
It does not.
Reproduction Steps
Provided above.
Possible Solution
No response
Additional Information/Context
No response
CDK CLI Version
2.138.0
Framework Version
No response
Node.js Version
20
OS
darwin
Language
TypeScript
Language Version
No response
Other information
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
@aws-cdk/aws-cloudwatchRelated to Amazon CloudWatchRelated to Amazon CloudWatchbugThis issue is a bug.This issue is a bug.effort/smallSmall work item – less than a day of effortSmall work item – less than a day of effortp2