AtLeastThreshold

class aws_cdk.aws_cloudwatch.AtLeastThreshold

Bases: object

Threshold configuration for the AT_LEAST composite alarm rule expression.

Use AtLeastThreshold.count() for an absolute number or AtLeastThreshold.percentage() for a percentage-based threshold.

ExampleMetadata:

infused

Example:

# alarm1: cloudwatch.Alarm
# alarm2: cloudwatch.Alarm
# alarm3: cloudwatch.Alarm
# alarm4: cloudwatch.Alarm


alarm_rule = cloudwatch.AlarmRule.any_of(
    cloudwatch.AlarmRule.all_of(
        cloudwatch.AlarmRule.any_of(alarm1,
            cloudwatch.AlarmRule.from_alarm(alarm2, cloudwatch.AlarmState.OK), alarm3),
        cloudwatch.AlarmRule.not(cloudwatch.AlarmRule.from_alarm(alarm4, cloudwatch.AlarmState.INSUFFICIENT_DATA)),
        # AT_LEAST with count: at least 2 of these alarms must be in ALARM state
        cloudwatch.AlarmRule.at_least(cloudwatch.AlarmState.ALARM,
            operands=[alarm1, alarm2, alarm3],
            threshold=cloudwatch.AtLeastThreshold.count(2)
        ),
        # AT_LEAST with percentage and NOT: at least 60% must NOT be in OK state
        cloudwatch.AlarmRule.at_least_not(cloudwatch.AlarmState.OK,
            operands=[alarm1, alarm2, alarm3],
            threshold=cloudwatch.AtLeastThreshold.percentage(60)
        )),
    cloudwatch.AlarmRule.from_boolean(False))

cloudwatch.CompositeAlarm(self, "MyAwesomeCompositeAlarm",
    alarm_rule=alarm_rule
)

Static Methods

classmethod count(count)

Creates a count-based threshold for the AT_LEAST expression.

The count must be a positive integer between 1 and the number of operands.

Parameters:

count (Union[int, float]) – the minimum number of alarms that must be in the specified state.

Return type:

AtLeastThreshold

classmethod percentage(percentage)

Creates a percentage-based threshold for the AT_LEAST expression.

The percentage must be an integer between 1 and 100.

Parameters:

percentage (Union[int, float]) – the minimum percentage of alarms that must be in the specified state.

Return type:

AtLeastThreshold