AtLeastOptions Struct
Options for the AT_LEAST AlarmRule wrapper function.
| Source | aws-cloudwatch/lib/alarm-rule.ts |
|---|---|
| Type last changed |
Example
ts
declare const alarm1: cloudwatch.Alarm;
declare const alarm2: cloudwatch.Alarm;
declare const alarm3: cloudwatch.Alarm;
declare const alarm4: cloudwatch.Alarm;
const alarmRule = cloudwatch.AlarmRule.anyOf(
cloudwatch.AlarmRule.allOf(
cloudwatch.AlarmRule.anyOf(
alarm1,
cloudwatch.AlarmRule.fromAlarm(alarm2, cloudwatch.AlarmState.OK),
alarm3,
),
cloudwatch.AlarmRule.not(cloudwatch.AlarmRule.fromAlarm(alarm4, cloudwatch.AlarmState.INSUFFICIENT_DATA)),
// AT_LEAST with count: at least 2 of these alarms must be in ALARM state
cloudwatch.AlarmRule.atLeast(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.atLeastNot(cloudwatch.AlarmState.OK, {
operands: [alarm1, alarm2, alarm3],
threshold: cloudwatch.AtLeastThreshold.percentage(60),
}),
),
cloudwatch.AlarmRule.fromBoolean(false),
);
new cloudwatch.CompositeAlarm(this, 'MyAwesomeCompositeAlarm', {
alarmRule,
});
python
# 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
)
java
Alarm alarm1;
Alarm alarm2;
Alarm alarm3;
Alarm alarm4;
IAlarmRule alarmRule = AlarmRule.anyOf(AlarmRule.allOf(AlarmRule.anyOf(alarm1, AlarmRule.fromAlarm(alarm2, AlarmState.OK), alarm3), AlarmRule.not(AlarmRule.fromAlarm(alarm4, AlarmState.INSUFFICIENT_DATA)), AlarmRule.atLeast(AlarmState.ALARM, AtLeastOptions.builder()
.operands(List.of(alarm1, alarm2, alarm3))
.threshold(AtLeastThreshold.count(2))
.build()), AlarmRule.atLeastNot(AlarmState.OK, AtLeastOptions.builder()
.operands(List.of(alarm1, alarm2, alarm3))
.threshold(AtLeastThreshold.percentage(60))
.build())), AlarmRule.fromBoolean(false));
CompositeAlarm.Builder.create(this, "MyAwesomeCompositeAlarm")
.alarmRule(alarmRule)
.build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
Alarm alarm1;
Alarm alarm2;
Alarm alarm3;
Alarm alarm4;
var alarmRule = AlarmRule.AnyOf(AlarmRule.AllOf(AlarmRule.AnyOf(alarm1, AlarmRule.FromAlarm(alarm2, AlarmState.OK), alarm3), AlarmRule.Not(AlarmRule.FromAlarm(alarm4, AlarmState.INSUFFICIENT_DATA)), AlarmRule.AtLeast(AlarmState.ALARM, new AtLeastOptions {
Operands = new [] { alarm1, alarm2, alarm3 },
Threshold = AtLeastThreshold.Count(2)
}), AlarmRule.AtLeastNot(AlarmState.OK, new AtLeastOptions {
Operands = new [] { alarm1, alarm2, alarm3 },
Threshold = AtLeastThreshold.Percentage(60)
})), AlarmRule.FromBoolean(false));
new CompositeAlarm(this, "MyAwesomeCompositeAlarm", new CompositeAlarmProps {
AlarmRule = alarmRule
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
var alarm1 Alarm
var alarm2 Alarm
var alarm3 Alarm
var alarm4 Alarm
alarmRule := cloudwatch.AlarmRule_AnyOf(cloudwatch.AlarmRule_AllOf(cloudwatch.AlarmRule_AnyOf(alarm1, cloudwatch.AlarmRule_FromAlarm(alarm2, cloudwatch.AlarmState_OK), alarm3), cloudwatch.AlarmRule_Not(cloudwatch.AlarmRule_FromAlarm(alarm4, cloudwatch.AlarmState_INSUFFICIENT_DATA)), cloudwatch.AlarmRule_AtLeast(cloudwatch.AlarmState_ALARM, &AtLeastOptions{
Operands: []IAlarm{
alarm1,
alarm2,
alarm3,
},
Threshold: cloudwatch.AtLeastThreshold_Count(jsii.Number(2)),
}), cloudwatch.AlarmRule_AtLeastNot(cloudwatch.AlarmState_OK, &AtLeastOptions{
Operands: []IAlarm{
alarm1,
alarm2,
alarm3,
},
Threshold: cloudwatch.AtLeastThreshold_Percentage(jsii.Number(60)),
})), cloudwatch.AlarmRule_FromBoolean(jsii.Boolean(false)))
cloudwatch.NewCompositeAlarm(this, jsii.String("MyAwesomeCompositeAlarm"), &CompositeAlarmProps{
AlarmRule: AlarmRule,
})
Properties
operandsIAlarm[]operandstyping.List[IAlarm]operandsList<IAlarm>OperandsIAlarm[]Operands*[]IAlarm required #Alarms to evaluate in the AT_LEAST expression.
Must contain at least one alarm.
thresholdAtLeastThresholdthresholdAtLeastThresholdthresholdAtLeastThresholdThresholdAtLeastThresholdThresholdAtLeastThreshold required #Threshold for the AT_LEAST expression.
Use AtLeastThreshold.count() for an absolute number or AtLeastThreshold.percentage() for a percentage.