aws-cdk-lib.aws_cloudwatch.AlarmRule

class AlarmRule

LanguageType name
.NETAmazon.CDK.AWS.CloudWatch.AlarmRule
Gogithub.com/aws/aws-cdk-go/awscdk/v2/awscloudwatch#AlarmRule
Javasoftware.amazon.awscdk.services.cloudwatch.AlarmRule
Pythonaws_cdk.aws_cloudwatch.AlarmRule
TypeScript (source)aws-cdk-lib » aws_cloudwatch » AlarmRule

Class with static functions to build AlarmRule for Composite Alarms.

Example

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)),
  ),
  cloudwatch.AlarmRule.fromBoolean(false),
);

new cloudwatch.CompositeAlarm(this, 'MyAwesomeCompositeAlarm', {
  alarmRule,
});

Initializer

new AlarmRule()

Methods

NameDescription
static allOf(...operands)function to join all provided AlarmRules with AND operator.
static anyOf(...operands)function to join all provided AlarmRules with OR operator.
static fromAlarm(alarm, alarmState)function to build Rule Expression for given IAlarm and AlarmState.
static fromBoolean(value)function to build TRUE/FALSE intent for Rule Expression.
static fromString(alarmRule)function to build Rule Expression for given Alarm Rule string.
static not(operand)function to wrap provided AlarmRule in NOT operator.

static allOf(...operands)

public static allOf(...operands: IAlarmRule[]): IAlarmRule

Parameters

  • operands IAlarmRule — IAlarmRules to be joined with AND operator.

Returns

  • IAlarmRule

function to join all provided AlarmRules with AND operator.


static anyOf(...operands)

public static anyOf(...operands: IAlarmRule[]): IAlarmRule

Parameters

  • operands IAlarmRule — IAlarmRules to be joined with OR operator.

Returns

  • IAlarmRule

function to join all provided AlarmRules with OR operator.


static fromAlarm(alarm, alarmState)

public static fromAlarm(alarm: IAlarm, alarmState: AlarmState): IAlarmRule

Parameters

  • alarm IAlarm — IAlarm to be used in Rule Expression.
  • alarmState AlarmState — AlarmState to be used in Rule Expression.

Returns

  • IAlarmRule

function to build Rule Expression for given IAlarm and AlarmState.


static fromBoolean(value)

public static fromBoolean(value: boolean): IAlarmRule

Parameters

  • value boolean — boolean value to be used in rule expression.

Returns

  • IAlarmRule

function to build TRUE/FALSE intent for Rule Expression.


static fromString(alarmRule)

public static fromString(alarmRule: string): IAlarmRule

Parameters

  • alarmRule string — string to be used in Rule Expression.

Returns

  • IAlarmRule

function to build Rule Expression for given Alarm Rule string.


static not(operand)

public static not(operand: IAlarmRule): IAlarmRule

Parameters

  • operand IAlarmRule — IAlarmRule to be wrapped in NOT operator.

Returns

  • IAlarmRule

function to wrap provided AlarmRule in NOT operator.