Skip to content
v2.275.0

AlarmRule Class ​

Class with static functions to build AlarmRule for Composite Alarms.

Example ​

ts
declare const alarm1: cloudwatch.Alarm;
declare const alarm2: cloudwatch.Alarm;
declare const onAlarmAction: cloudwatch.IAlarmAction;
declare const onOkAction: cloudwatch.IAlarmAction;
declare const actionsSuppressor: cloudwatch.Alarm;

const alarmRule = cloudwatch.AlarmRule.anyOf(alarm1, alarm2);

const myCompositeAlarm = new cloudwatch.CompositeAlarm(this, 'MyAwesomeCompositeAlarm', {
  alarmRule,
  actionsSuppressor,
});
myCompositeAlarm.addAlarmAction(onAlarmAction);
myCompositeAlarm.addOkAction(onOkAction);
python
# alarm1: cloudwatch.Alarm
# alarm2: cloudwatch.Alarm
# on_alarm_action: cloudwatch.IAlarmAction
# on_ok_action: cloudwatch.IAlarmAction
# actions_suppressor: cloudwatch.Alarm


alarm_rule = cloudwatch.AlarmRule.any_of(alarm1, alarm2)

my_composite_alarm = cloudwatch.CompositeAlarm(self, "MyAwesomeCompositeAlarm",
    alarm_rule=alarm_rule,
    actions_suppressor=actions_suppressor
)
my_composite_alarm.add_alarm_action(on_alarm_action)
my_composite_alarm.add_ok_action(on_ok_action)
java
Alarm alarm1;
Alarm alarm2;
IAlarmAction onAlarmAction;
IAlarmAction onOkAction;
Alarm actionsSuppressor;


IAlarmRule alarmRule = AlarmRule.anyOf(alarm1, alarm2);

CompositeAlarm myCompositeAlarm = CompositeAlarm.Builder.create(this, "MyAwesomeCompositeAlarm")
        .alarmRule(alarmRule)
        .actionsSuppressor(actionsSuppressor)
        .build();
myCompositeAlarm.addAlarmAction(onAlarmAction);
myCompositeAlarm.addOkAction(onOkAction);
csharp
// Install: dotnet add package Amazon.CDK.Lib
Alarm alarm1;
Alarm alarm2;
IAlarmAction onAlarmAction;
IAlarmAction onOkAction;
Alarm actionsSuppressor;


var alarmRule = AlarmRule.AnyOf(alarm1, alarm2);

var myCompositeAlarm = new CompositeAlarm(this, "MyAwesomeCompositeAlarm", new CompositeAlarmProps {
    AlarmRule = alarmRule,
    ActionsSuppressor = actionsSuppressor
});
myCompositeAlarm.AddAlarmAction(onAlarmAction);
myCompositeAlarm.AddOkAction(onOkAction);
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
var alarm1 Alarm
var alarm2 Alarm
var onAlarmAction IAlarmAction
var onOkAction IAlarmAction
var actionsSuppressor Alarm


alarmRule := cloudwatch.AlarmRule_AnyOf(alarm1, alarm2)

myCompositeAlarm := cloudwatch.NewCompositeAlarm(this, jsii.String("MyAwesomeCompositeAlarm"), &CompositeAlarmProps{
	AlarmRule: AlarmRule,
	ActionsSuppressor: ActionsSuppressor,
})
myCompositeAlarm.AddAlarmAction(onAlarmAction)
myCompositeAlarm.AddOkAction(onOkAction)

Initializer ​

ts
new AlarmRule()
python
AlarmRule()
java
new AlarmRule()
csharp
new AlarmRule()
go
NewAlarmRule()

Methods ​

allOf(...operands: IAlarmRule[]): IAlarmRule@staticmethod def all_of(operands: IAlarmRule) -> IAlarmRulepublic static IAlarmRule allOf(IAlarmRule operands)public static IAlarmRule AllOf(IAlarmRule operands)func AllOf(Operands IAlarmRule) IAlarmRulestatic#
function to join all provided AlarmRules with AND operator.
1 parameter

Parameters

  • operandsoperandsoperandsoperandsOperands — IAlarmRules to be joined with AND operator.
anyOf(...operands: IAlarmRule[]): IAlarmRule@staticmethod def any_of(operands: IAlarmRule) -> IAlarmRulepublic static IAlarmRule anyOf(IAlarmRule operands)public static IAlarmRule AnyOf(IAlarmRule operands)func AnyOf(Operands IAlarmRule) IAlarmRulestatic#
function to join all provided AlarmRules with OR operator.
1 parameter

Parameters

  • operandsoperandsoperandsoperandsOperands — IAlarmRules to be joined with OR operator.
atLeast(alarmState: AlarmState, options: AtLeastOptions): IAlarmRule@staticmethod def at_least(alarm_state: AlarmState, options: AtLeastOptions) -> IAlarmRulepublic static IAlarmRule atLeast(AlarmState alarmState, AtLeastOptions options)public static IAlarmRule AtLeast(AlarmState alarmState, AtLeastOptions options)func AtLeast(AlarmState AlarmState, Options AtLeastOptions) IAlarmRulestatic#
function to create an AT_LEAST expression for the given alarm state.
2 parameters

Parameters

  • alarmStatealarm_statealarmStatealarmStateAlarmState — the alarm state to evaluate against.
  • optionsoptionsoptionsoptionsOptions — operands and threshold for the AT_LEAST expression.
atLeastNot(alarmState: AlarmState, options: AtLeastOptions): IAlarmRule@staticmethod def at_least_not(alarm_state: AlarmState, options: AtLeastOptions) -> IAlarmRulepublic static IAlarmRule atLeastNot(AlarmState alarmState, AtLeastOptions options)public static IAlarmRule AtLeastNot(AlarmState alarmState, AtLeastOptions options)func AtLeastNot(AlarmState AlarmState, Options AtLeastOptions) IAlarmRulestatic#
function to create an AT_LEAST expression for the negated alarm state.
2 parameters

Parameters

  • alarmStatealarm_statealarmStatealarmStateAlarmState — the alarm state to negate and evaluate against.
  • optionsoptionsoptionsoptionsOptions — operands and threshold for the AT_LEAST expression.
fromAlarm(alarm: IAlarmRef, alarmState: AlarmState): IAlarmRule@staticmethod def from_alarm(alarm: IAlarmRef, alarm_state: AlarmState) -> IAlarmRulepublic static IAlarmRule fromAlarm(IAlarmRef alarm, AlarmState alarmState)public static IAlarmRule FromAlarm(IAlarmRef alarm, AlarmState alarmState)func FromAlarm(Alarm IAlarmRef, AlarmState AlarmState) IAlarmRulestatic#
function to build Rule Expression for given IAlarm and AlarmState.
2 parameters

Parameters

  • alarmalarmalarmalarmAlarm — IAlarm to be used in Rule Expression.
  • alarmStatealarm_statealarmStatealarmStateAlarmState — AlarmState to be used in Rule Expression.
fromBoolean(value: boolean): IAlarmRule@staticmethod def from_boolean(value: bool) -> IAlarmRulepublic static IAlarmRule fromBoolean(Boolean value)public static IAlarmRule FromBoolean(bool value)func FromBoolean(Value *bool) IAlarmRulestatic#
function to build TRUE/FALSE intent for Rule Expression.
1 parameter

Parameters

  • valuevaluevaluevalueValue — boolean value to be used in rule expression.
fromString(alarmRule: string): IAlarmRule@staticmethod def from_string(alarm_rule: str) -> IAlarmRulepublic static IAlarmRule fromString(String alarmRule)public static IAlarmRule FromString(string alarmRule)func FromString(AlarmRule *string) IAlarmRulestatic#
function to build Rule Expression for given Alarm Rule string.
1 parameter

Parameters

  • alarmRulealarm_rulealarmRulealarmRuleAlarmRule — string to be used in Rule Expression.
not(operand: IAlarmRule): IAlarmRule@staticmethod def not(operand: IAlarmRule) -> IAlarmRulepublic static IAlarmRule not(IAlarmRule operand)public static IAlarmRule Not(IAlarmRule operand)func Not(Operand IAlarmRule) IAlarmRulestatic#
function to wrap provided AlarmRule in NOT operator.
1 parameter

Parameters

  • operandoperandoperandoperandOperand — IAlarmRule to be wrapped in NOT operator.