# AlarmRule

Class with static functions to build AlarmRule for Composite Alarms.

- Source: [`aws-cloudwatch/lib/alarm-rule.ts`](https://github.com/aws/aws-cdk/blob/v2.275.0/packages/aws-cdk-lib/aws-cloudwatch/lib/alarm-rule.ts#L157)
- Type last changed: v2.265.0 · 13 Aug 2026

## 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);
```

## Initializer

```ts
new AlarmRule()
```

## Methods

- `allOf(...operands: IAlarmRule[]): IAlarmRule` (static) — function to join all provided AlarmRules with AND operator.

  **Parameters**

  - `operands` — IAlarmRules to be joined with AND operator.

- `anyOf(...operands: IAlarmRule[]): IAlarmRule` (static) — function to join all provided AlarmRules with OR operator.

  **Parameters**

  - `operands` — IAlarmRules to be joined with OR operator.

- `atLeast(alarmState: AlarmState, options: AtLeastOptions): IAlarmRule` (static) — function to create an AT_LEAST expression for the given alarm state.

  **Parameters**

  - `alarmState` — the alarm state to evaluate against.
  - `options` — operands and threshold for the AT_LEAST expression.

- `atLeastNot(alarmState: AlarmState, options: AtLeastOptions): IAlarmRule` (static) — function to create an AT_LEAST expression for the negated alarm state.

  **Parameters**

  - `alarmState` — the alarm state to negate and evaluate against.
  - `options` — operands and threshold for the AT_LEAST expression.

- `fromAlarm(alarm: IAlarmRef, alarmState: AlarmState): IAlarmRule` (static) — function to build Rule Expression for given IAlarm and AlarmState.

  **Parameters**

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

- `fromBoolean(value: boolean): IAlarmRule` (static) — function to build TRUE/FALSE intent for Rule Expression.

  **Parameters**

  - `value` — boolean value to be used in rule expression.

- `fromString(alarmRule: string): IAlarmRule` (static) — function to build Rule Expression for given Alarm Rule string.

  **Parameters**

  - `alarmRule` — string to be used in Rule Expression.

- `not(operand: IAlarmRule): IAlarmRule` (static) — function to wrap provided AlarmRule in NOT operator.

  **Parameters**

  - `operand` — IAlarmRule to be wrapped in NOT operator.
