Skip to content

feat(alarm): Support AT_LEAST when creating composite alarm#691

Open
Laxenade wants to merge 3 commits intocdklabs:mainfrom
Laxenade:at-least-composite-alarm
Open

feat(alarm): Support AT_LEAST when creating composite alarm#691
Laxenade wants to merge 3 commits intocdklabs:mainfrom
Laxenade:at-least-composite-alarm

Conversation

@Laxenade
Copy link
Contributor

Adding support for creating composite alarms using the new AT_LEAST operator. The corresponding change in cdk-lib has not been merged aws/aws-cdk#36100, and historically, this package lags behind cdk-lib by several months. Therefore, instead of using the new construct in cdk-lib, we will compose the alarm string ourselves. This is not a big deal since most of the code in the PR is still necessary. The only aspect that may change once we have the construct in cdk-lib is likely the last few lines in determineCompositeAlarmRule.


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@Laxenade Laxenade changed the title Support AT_LEAST when creating composite alarm (feat) Support AT_LEAST when creating composite alarm Dec 18, 2025
@Laxenade Laxenade changed the title (feat) Support AT_LEAST when creating composite alarm feat(alarm): Support AT_LEAST when creating composite alarm Dec 18, 2025
@Laxenade Laxenade marked this pull request as ready for review December 19, 2025 00:00
@cdklabs-automation cdklabs-automation enabled auto-merge (squash) December 19, 2025 00:00
/**
* @internal
*/
public abstract _renderThreshold(): string;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not a similar _bind(_operands: IAlarm[]) approach like the aws-cdk PR, which would let you avoid needing to do the checks out in determineCompositeAlarmRule instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because, unlike in _bind(), we don’t have access to the alarms in _renderThreshold(), so we can’t check the alarm count there. My initial approach was to put the common logic (i.e. 0 <= count, 0 <= percentage <= 100) in _renderThreshold() and the count-specific logic (i.e. count <= num of alarm) in determineCompositeAlarmRule, but I couldn’t convince myself having validation split across two places. In the end, I moved everything into determineCompositeAlarmRule.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although, on second thought, I could probably just pass the alarms into _renderThreshold() and move the validations there.

auto-merge was automatically disabled December 21, 2025 08:07

Head branch was pushed to by a user without write access

Copy link
Contributor

@arkon arkon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, although I don't have write permissions.

@Laxenade
Copy link
Contributor Author

Laxenade commented Jan 5, 2026

@giantcow Mind taking a look when you have time? Thanks!

super();
}

public _renderThreshold(alarms: IAlarm[]): string {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Laxenade Laxenade force-pushed the at-least-composite-alarm branch from bbcdd48 to 4acb36f Compare January 15, 2026 08:47
@Laxenade Laxenade requested a review from giantcow January 15, 2026 08:50
@Laxenade Laxenade force-pushed the at-least-composite-alarm branch from 4acb36f to 5d3be00 Compare January 24, 2026 08:08
@Laxenade
Copy link
Contributor Author

@giantcow Bump

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants