Describe the feature
The AlarmRule class in aws-cdk-lib/aws-cloudwatch does not support the AT_LEAST function for composite alarm rule expressions.
Since November 2025, CloudWatch supports threshold-based alerting in composite alarms via the AT_LEAST function. This allows a composite alarm to trigger when a minimum number or percentage of child alarms are in a specified state.
The CloudFormation syntax is:
AT_LEAST(threshold, state, (alarm_arn_1, alarm_arn_2, ...))
Where threshold is either an integer (e.g. 2) or a percentage (e.g. 60%), and state is one of ALARM, OK, INSUFFICIENT_DATA, NOT ALARM, NOT OK, or NOT INSUFFICIENT_DATA.
Currently, users must fall back to AlarmRule.fromString() with a hand-crafted expression string to use this feature, losing type safety and ARN resolution.
A previous PR (#36100) attempted to implement this but was closed due to inactivity. Let's have this classic issue/PR pair and push this into the L2 pattern.
Use Case
When monitoring clusters, storage arrays, or microservice fleets, it is common to want alerts only when a critical mass of resources is affected rather than a single one. Examples:
- Alert when at least 2 out of 4 storage volumes are running low on capacity
- Alert when at least 50% of hosts in a cluster show high CPU utilization
- Alert when at least 3 out of 10 microservices report elevated error rates
Without L2 support, users must construct raw rule expression strings, which is error-prone and does not benefit from CDK's token resolution for alarm ARNs.
Proposed Solution
Add two new static methods to AlarmRule and a threshold class:
// Trigger when at least 2 of 3 alarms are in ALARM state
AlarmRule.atLeast(AlarmState.ALARM, {
operands: [alarm1, alarm2, alarm3],
threshold: AtLeastThreshold.count(2),
});
// Trigger when at least 60% of alarms are NOT in OK state
AlarmRule.atLeastNot(AlarmState.OK, {
operands: [alarm1, alarm2, alarm3],
threshold: AtLeastThreshold.percentage(60),
});
I am planning to submit a PR for this feature.
Other Information
Acknowledgements
AWS CDK Library version (aws-cdk-lib)
2.251.0
AWS CDK CLI version
2.1119.0
Environment details (OS name and version, etc.)
Fedora 43
Describe the feature
The
AlarmRuleclass inaws-cdk-lib/aws-cloudwatchdoes not support theAT_LEASTfunction for composite alarm rule expressions.Since November 2025, CloudWatch supports threshold-based alerting in composite alarms via the
AT_LEASTfunction. This allows a composite alarm to trigger when a minimum number or percentage of child alarms are in a specified state.The CloudFormation syntax is:
Where
thresholdis either an integer (e.g.2) or a percentage (e.g.60%), andstateis one ofALARM,OK,INSUFFICIENT_DATA,NOT ALARM,NOT OK, orNOT INSUFFICIENT_DATA.Currently, users must fall back to
AlarmRule.fromString()with a hand-crafted expression string to use this feature, losing type safety and ARN resolution.A previous PR (#36100) attempted to implement this but was closed due to inactivity. Let's have this classic issue/PR pair and push this into the L2 pattern.
Use Case
When monitoring clusters, storage arrays, or microservice fleets, it is common to want alerts only when a critical mass of resources is affected rather than a single one. Examples:
Without L2 support, users must construct raw rule expression strings, which is error-prone and does not benefit from CDK's token resolution for alarm ARNs.
Proposed Solution
Add two new static methods to
AlarmRuleand a threshold class:I am planning to submit a PR for this feature.
Other Information
AT_LEASTwrapper function of comopsite alarm #36100Acknowledgements
AWS CDK Library version (aws-cdk-lib)
2.251.0
AWS CDK CLI version
2.1119.0
Environment details (OS name and version, etc.)
Fedora 43