Skip to content

(aws-cloudwatch): Metric widget can't display composite alarm #35001

@ruslan-roboto

Description

@ruslan-roboto

Describe the bug

This might actually be a bug in CloudWatch itself, but I didn't know where else to report it.

According to the documentation of the CW metric widget body structure, it should be possible to use a metric widget to display an alarm, provided that the annotations property is used like so:

"annotations": {
   "alarms": [ "arn1" ]
}

As of today, in my CW dashboards, this only works for metric alarms, but not composite alarms. For a composite alarm, I get the message Alarm FooCompositeAlarm in region <region> is missing or deleted. I don't have a good sense of when this stopped working, but it was working on June 9. Editing the dashboard source manually to change the widget type to alarm, using the same alarm ARN, results in a working widget that correctly reports the status of my composite alarm.

Things I've tried to isolate the root cause:

  • Different browsers: Chrome and Firefox
  • Incognito mode to exclude browser caching as a culprit

Regression Issue

  • Select this option if this issue appears to be a regression.

Last Known Working CDK Library Version

No response

Expected Behavior

I expect my dashboard metric widget to display my composite alarm.

Current Behavior

Metric widget claims the composite alarm doesn't exist, while I can clearly see it in CloudWatch, and I can graph it using an alarm widget.

Reproduction Steps

Create a CloudWatch dashboard with a metric widget which displays a composite alarm.

The CDK code for generating the composite alarm from several individual metric alarms looks like:

    return new cw.CompositeAlarm(this.scope, `${feature.featureName}Alarm`, {
      compositeAlarmName: generateName("AggregateAlarm"),
      alarmRule: cw.AlarmRule.anyOf(...alarms),
      alarmDescription: `Any alarm from the ${feature.featureName} subsystem has triggered.`,
    });

Alarms then get added as metric widgets to the dashboard like so:

   const alarmWidgets = this.alarms.map(
      (alarm) =>
        new cloudwatch.AlarmWidget({
          title: alarm.alarmName,
          alarm: alarm,
        }),
    );

    dashboard.addWidgets(new cloudwatch.Row(...alarmWidgets));

Possible Solution

No response

Additional Information/Context

No response

AWS CDK Library version (aws-cdk-lib)

2.201.0

AWS CDK CLI version

2.1003.0 (build b242c23)

Node.js Version

v20.18.1

OS

MacOS Sonoma 14.7.6

Language

TypeScript

Language Version

No response

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions