aws-cdk-lib.aws_cloudwatch.CompositeAlarm

class CompositeAlarm (construct)

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

Implements IConstruct, IDependable, IResource, IAlarm, IAlarmRule

A Composite Alarm based on Alarm Rule.

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 CompositeAlarm(scope: Construct, id: string, props: CompositeAlarmProps)

Parameters

  • scope Construct
  • id string
  • props CompositeAlarmProps

Construct Props

NameTypeDescription
alarmRuleIAlarmRuleExpression that specifies which other alarms are to be evaluated to determine this composite alarm's state.
actionsEnabled?booleanWhether the actions for this alarm are enabled.
actionsSuppressor?IAlarmActions will be suppressed if the suppressor alarm is in the ALARM state.
actionsSuppressorExtensionPeriod?DurationThe maximum duration that the composite alarm waits after suppressor alarm goes out of the ALARM state.
actionsSuppressorWaitPeriod?DurationThe maximum duration that the composite alarm waits for the suppressor alarm to go into the ALARM state.
alarmDescription?stringDescription for the alarm.
compositeAlarmName?stringName of the alarm.

alarmRule

Type: IAlarmRule

Expression that specifies which other alarms are to be evaluated to determine this composite alarm's state.


actionsEnabled?

Type: boolean (optional, default: true)

Whether the actions for this alarm are enabled.


actionsSuppressor?

Type: IAlarm (optional, default: alarm will not be suppressed.)

Actions will be suppressed if the suppressor alarm is in the ALARM state.


actionsSuppressorExtensionPeriod?

Type: Duration (optional, default: 1 minute extension period will be set.)

The maximum duration that the composite alarm waits after suppressor alarm goes out of the ALARM state.

After this time, the composite alarm performs its actions.


actionsSuppressorWaitPeriod?

Type: Duration (optional, default: 1 minute wait period will be set.)

The maximum duration that the composite alarm waits for the suppressor alarm to go into the ALARM state.

After this time, the composite alarm performs its actions.


alarmDescription?

Type: string (optional, default: No description.)

Description for the alarm.


compositeAlarmName?

Type: string (optional, default: Automatically generated name.)

Name of the alarm.

Properties

NameTypeDescription
alarmArnstringARN of this alarm.
alarmNamestringName of this alarm.
envResourceEnvironmentThe environment this resource belongs to.
nodeNodeThe tree node.
stackStackThe stack in which this resource is defined.

alarmArn

Type: string

ARN of this alarm.


alarmName

Type: string

Name of this alarm.


env

Type: ResourceEnvironment

The environment this resource belongs to.

For resources that are created and managed by the CDK (generally, those created by creating new class instances like Role, Bucket, etc.), this is always the same as the environment of the stack they belong to; however, for imported resources (those obtained from static methods like fromRoleArn, fromBucketName, etc.), that might be different than the stack they were imported into.


node

Type: Node

The tree node.


stack

Type: Stack

The stack in which this resource is defined.

Methods

NameDescription
addAlarmAction(...actions)Trigger this action if the alarm fires.
addInsufficientDataAction(...actions)Trigger this action if there is insufficient data to evaluate the alarm.
addOkAction(...actions)Trigger this action if the alarm returns from breaching state into ok state.
applyRemovalPolicy(policy)Apply the given removal policy to this resource.
renderAlarmRule()AlarmRule indicating ALARM state for Alarm.
toString()Returns a string representation of this construct.
static fromCompositeAlarmArn(scope, id, compositeAlarmArn)Import an existing CloudWatch composite alarm provided an ARN.
static fromCompositeAlarmName(scope, id, compositeAlarmName)Import an existing CloudWatch composite alarm provided an Name.

addAlarmAction(...actions)

public addAlarmAction(...actions: IAlarmAction[]): void

Parameters

  • actions IAlarmAction

Trigger this action if the alarm fires.

Typically SnsAcion or AutoScalingAction.


addInsufficientDataAction(...actions)

public addInsufficientDataAction(...actions: IAlarmAction[]): void

Parameters

  • actions IAlarmAction

Trigger this action if there is insufficient data to evaluate the alarm.

Typically SnsAcion or AutoScalingAction.


addOkAction(...actions)

public addOkAction(...actions: IAlarmAction[]): void

Parameters

  • actions IAlarmAction

Trigger this action if the alarm returns from breaching state into ok state.

Typically SnsAcion or AutoScalingAction.


applyRemovalPolicy(policy)

public applyRemovalPolicy(policy: RemovalPolicy): void

Parameters

  • policy RemovalPolicy

Apply the given removal policy to this resource.

The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you've removed it from the CDK application or because you've made a change that requires the resource to be replaced.

The resource can be deleted (RemovalPolicy.DESTROY), or left in your AWS account for data recovery and cleanup later (RemovalPolicy.RETAIN).


renderAlarmRule()

public renderAlarmRule(): string

Returns

  • string

AlarmRule indicating ALARM state for Alarm.


toString()

public toString(): string

Returns

  • string

Returns a string representation of this construct.


static fromCompositeAlarmArn(scope, id, compositeAlarmArn)

public static fromCompositeAlarmArn(scope: Construct, id: string, compositeAlarmArn: string): IAlarm

Parameters

  • scope Construct — The parent creating construct (usually this).
  • id string — The construct's name.
  • compositeAlarmArn string — Composite Alarm ARN (i.e. arn:aws:cloudwatch::<account-id>:alarm:CompositeAlarmName).

Returns

  • IAlarm

Import an existing CloudWatch composite alarm provided an ARN.


static fromCompositeAlarmName(scope, id, compositeAlarmName)

public static fromCompositeAlarmName(scope: Construct, id: string, compositeAlarmName: string): IAlarm

Parameters

  • scope Construct — The parent creating construct (usually this).
  • id string — The construct's name.
  • compositeAlarmName string — Composite Alarm Name.

Returns

  • IAlarm

Import an existing CloudWatch composite alarm provided an Name.