Class Alarm
java.lang.Object
software.amazon.jsii.JsiiObject
software.constructs.Construct
software.amazon.awscdk.core.Construct
software.amazon.awscdk.core.Resource
software.amazon.awscdk.services.cloudwatch.AlarmBase
software.amazon.awscdk.services.cloudwatch.Alarm
- All Implemented Interfaces:
IConstruct,IDependable,IResource,IAlarm,IAlarmRule,software.amazon.jsii.JsiiSerializable,software.constructs.IConstruct
@Generated(value="jsii-pacmak/1.84.0 (build 5404dcf)",
date="2023-06-19T16:30:36.764Z")
@Stability(Stable)
public class Alarm
extends AlarmBase
An alarm on a CloudWatch metric.
Example:
import software.amazon.awscdk.services.cloudwatch.*;
Alias alias;
// or add alarms to an existing group
Alias blueGreenAlias;
Alarm alarm = Alarm.Builder.create(this, "Errors")
.comparisonOperator(ComparisonOperator.GREATER_THAN_THRESHOLD)
.threshold(1)
.evaluationPeriods(1)
.metric(alias.metricErrors())
.build();
LambdaDeploymentGroup deploymentGroup = LambdaDeploymentGroup.Builder.create(this, "BlueGreenDeployment")
.alias(alias)
.deploymentConfig(LambdaDeploymentConfig.LINEAR_10PERCENT_EVERY_1MINUTE)
.alarms(List.of(alarm))
.build();
deploymentGroup.addAlarm(Alarm.Builder.create(this, "BlueGreenErrors")
.comparisonOperator(ComparisonOperator.GREATER_THAN_THRESHOLD)
.threshold(1)
.evaluationPeriods(1)
.metric(blueGreenAlias.metricErrors())
.build());
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class software.amazon.jsii.JsiiObject
software.amazon.jsii.JsiiObject.InitializationModeNested classes/interfaces inherited from interface software.amazon.awscdk.services.cloudwatch.IAlarm
IAlarm.Jsii$DefaultNested classes/interfaces inherited from interface software.amazon.awscdk.core.IConstruct
IConstruct.Jsii$DefaultNested classes/interfaces inherited from interface software.constructs.IConstruct
software.constructs.IConstruct.Jsii$DefaultNested classes/interfaces inherited from interface software.amazon.awscdk.core.IResource
IResource.Jsii$Default -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAlarm(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) protectedAlarm(software.amazon.jsii.JsiiObjectRef objRef) Alarm(software.constructs.Construct scope, String id, AlarmProps props) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAlarmAction(@NotNull IAlarmAction... actions) Trigger this action if the alarm fires.static IAlarmfromAlarmArn(software.constructs.Construct scope, String id, String alarmArn) Import an existing CloudWatch alarm provided an ARN.ARN of this alarm.Name of this alarm.The metric object this alarm was based on.Turn this alarm into a horizontal annotation.Methods inherited from class software.amazon.awscdk.services.cloudwatch.AlarmBase
addInsufficientDataAction, addOkAction, getAlarmActionArns, getInsufficientDataActionArns, getOkActionArns, renderAlarmRule, setAlarmActionArns, setInsufficientDataActionArns, setOkActionArnsMethods inherited from class software.amazon.awscdk.core.Resource
applyRemovalPolicy, generatePhysicalName, getEnv, getPhysicalName, getResourceArnAttribute, getResourceNameAttribute, getStack, isResourceMethods inherited from class software.amazon.awscdk.core.Construct
getNode, isConstruct, onPrepare, onSynthesize, onValidate, prepare, synthesize, validateMethods inherited from class software.constructs.Construct
toStringMethods inherited from class software.amazon.jsii.JsiiObject
jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSetMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface software.amazon.awscdk.core.IConstruct
getNodeMethods inherited from interface software.amazon.awscdk.core.IResource
applyRemovalPolicy, getEnv, getStackMethods inherited from interface software.amazon.jsii.JsiiSerializable
$jsii$toJson
-
Constructor Details
-
Alarm
protected Alarm(software.amazon.jsii.JsiiObjectRef objRef) -
Alarm
protected Alarm(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) -
Alarm
@Stability(Stable) public Alarm(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull AlarmProps props) - Parameters:
scope- This parameter is required.id- This parameter is required.props- This parameter is required.
-
-
Method Details
-
fromAlarmArn
@Stability(Stable) @NotNull public static IAlarm fromAlarmArn(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull String alarmArn) Import an existing CloudWatch alarm provided an ARN.- Parameters:
scope- The parent creating construct (usuallythis). This parameter is required.id- The construct's name. This parameter is required.alarmArn- Alarm ARN (i.e. arn:aws:cloudwatch::<account-id>:alarm:Foo). This parameter is required.
-
addAlarmAction
Trigger this action if the alarm fires.Typically the ARN of an SNS topic or ARN of an AutoScaling policy.
- Overrides:
addAlarmActionin classAlarmBase- Parameters:
actions- This parameter is required.
-
toAnnotation
Turn this alarm into a horizontal annotation.This is useful if you want to represent an Alarm in a non-AlarmWidget. An
AlarmWidgetcan directly show an alarm, but it can only show a single alarm and no other metrics. Instead, you can convert the alarm to a HorizontalAnnotation and add it as an annotation to another graph.This might be useful if:
- You want to show multiple alarms inside a single graph, for example if you have both a "small margin/long period" alarm as well as a "large margin/short period" alarm.
- You want to show an Alarm line in a graph with multiple metrics in it.
-
getAlarmArn
ARN of this alarm.- Specified by:
getAlarmArnin interfaceIAlarm- Specified by:
getAlarmArnin classAlarmBase
-
getAlarmName
Name of this alarm.- Specified by:
getAlarmNamein interfaceIAlarm- Specified by:
getAlarmNamein classAlarmBase
-
getMetric
The metric object this alarm was based on.
-