class CompositeAlarm (construct)
Language | Type name |
---|---|
![]() | Amazon.CDK.AWS.CloudWatch.CompositeAlarm |
![]() | software.amazon.awscdk.services.cloudwatch.CompositeAlarm |
![]() | aws_cdk.aws_cloudwatch.CompositeAlarm |
![]() | @aws-cdk/aws-cloudwatch » CompositeAlarm |
Implements
IConstruct
, IConstruct
, IDependable
, IResource
, IAlarm
, IAlarm
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
Composite
Alarm Props
Construct Props
Name | Type | Description |
---|---|---|
alarm | IAlarm | Expression that specifies which other alarms are to be evaluated to determine this composite alarm's state. |
actions | boolean | Whether the actions for this alarm are enabled. |
alarm | string | Description for the alarm. |
composite | string | Name of the alarm. |
alarmRule
Type:
IAlarm
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.
alarmDescription?
Type:
string
(optional, default: No description)
Description for the alarm.
compositeAlarmName?
Type:
string
(optional, default: Automatically generated name)
Name of the alarm.
Properties
Name | Type | Description |
---|---|---|
alarm | string | ARN of this alarm. |
alarm | string | Name of this alarm. |
env | Resource | The environment this resource belongs to. |
node | Construct | The construct tree node associated with this construct. |
stack | Stack | The stack in which this resource is defined. |
alarmArn
Type:
string
ARN of this alarm.
alarmName
Type:
string
Name of this alarm.
env
Type:
Resource
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:
Construct
The construct tree node associated with this construct.
stack
Type:
Stack
The stack in which this resource is defined.
Methods
Name | Description |
---|---|
add | Trigger this action if the alarm fires. |
add | Trigger this action if there is insufficient data to evaluate the alarm. |
add | Trigger this action if the alarm returns from breaching state into ok state. |
apply | Apply the given removal policy to this resource. |
render | AlarmRule indicating ALARM state for Alarm. |
to | Returns a string representation of this construct. |
static from | Import an existing CloudWatch composite alarm provided an ARN. |
static from | Import an existing CloudWatch composite alarm provided an Name. |
addAlarmAction(...actions)
public addAlarmAction(...actions: IAlarmAction[]): void
Parameters
- actions
IAlarm
Action
Trigger this action if the alarm fires.
Typically the ARN of an SNS topic or ARN of an AutoScaling policy.
addInsufficientDataAction(...actions)
public addInsufficientDataAction(...actions: IAlarmAction[]): void
Parameters
- actions
IAlarm
Action
Trigger this action if there is insufficient data to evaluate the alarm.
Typically the ARN of an SNS topic or ARN of an AutoScaling policy.
addOkAction(...actions)
public addOkAction(...actions: IAlarmAction[]): void
Parameters
- actions
IAlarm
Action
Trigger this action if the alarm returns from breaching state into ok state.
Typically the ARN of an SNS topic or ARN of an AutoScaling policy.
applyRemovalPolicy(policy)
public applyRemovalPolicy(policy: RemovalPolicy): void
Parameters
- policy
Removal
Policy
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 (usuallythis
). - id
string
— The construct's name. - compositeAlarmArn
string
— Composite Alarm ARN (i.e. arn:aws:cloudwatch::<account-id>:alarm/CompositeAlarmName).
Returns
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 (usuallythis
). - id
string
— The construct's name. - compositeAlarmName
string
— Composite Alarm Name.
Returns
Import an existing CloudWatch composite alarm provided an Name.