Skip to content

Commit 278029f

Browse files
authored
fix(cloudwatch): cannot create Alarms from labeled metrics that start with a digit (#13560)
fixes #13434 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent d3f4284 commit 278029f

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

packages/@aws-cdk/aws-cloudwatch/lib/alarm.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,6 @@ export class Alarm extends AlarmBase {
257257
return dispatchMetric(metric, {
258258
withStat(stat, conf) {
259259
self.validateMetricStat(stat, metric);
260-
261260
if (conf.renderingProperties?.label == undefined) {
262261
return dropUndefined({
263262
dimensions: stat.dimensions,
@@ -283,7 +282,7 @@ export class Alarm extends AlarmBase {
283282
stat: stat.statistic,
284283
unit: stat.unitFilter,
285284
},
286-
id: stat.metricName,
285+
id: 'm1',
287286
label: conf.renderingProperties?.label,
288287
returnData: true,
289288
} as CfnAlarm.MetricDataQueryProperty,

packages/@aws-cdk/aws-cloudwatch/test/integ.alarm-with-label.expected.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"Properties": {
66
"Metrics": [
77
{
8-
"Id": "Metric",
8+
"Id": "m1",
99
"Label": "Metric [AVG: ${AVG}]",
1010
"MetricStat": {
1111
"Metric": {
@@ -28,7 +28,7 @@
2828
"Properties": {
2929
"Metrics": [
3030
{
31-
"Id": "Metric",
31+
"Id": "m1",
3232
"Label": "Metric [AVG: ${AVG}]",
3333
"MetricStat": {
3434
"Metric": {

0 commit comments

Comments
 (0)