Class Alarm
java.lang.Object
software.amazon.jsii.JsiiObject
software.constructs.Construct
software.amazon.awscdk.Resource
software.amazon.awscdk.services.cloudwatch.AlarmBase
software.amazon.awscdk.services.cloudwatch.Alarm
- All Implemented Interfaces:
IResource
,IAlarm
,IAlarmRule
,software.amazon.jsii.JsiiSerializable
,software.constructs.IConstruct
,software.constructs.IDependable
@Generated(value="jsii-pacmak/1.103.1 (build bef2dea)",
date="2024-10-11T15:55:54.723Z")
@Stability(Stable)
public class Alarm
extends AlarmBase
An alarm on a CloudWatch metric.
Example:
LogGroup logGroup; MetricFilter mf = MetricFilter.Builder.create(this, "MetricFilter") .logGroup(logGroup) .metricNamespace("MyApp") .metricName("Latency") .filterPattern(FilterPattern.exists("$.latency")) .metricValue("$.latency") .dimensions(Map.of( "ErrorCode", "$.errorCode")) .unit(Unit.MILLISECONDS) .build(); //expose a metric from the metric filter Metric metric = mf.metric(); //you can use the metric to create a new alarm //you can use the metric to create a new alarm Alarm.Builder.create(this, "alarm from metric filter") .metric(metric) .threshold(100) .evaluationPeriods(2) .build();
-
Nested Class Summary
Nested classes/interfaces inherited from class software.amazon.jsii.JsiiObject
software.amazon.jsii.JsiiObject.InitializationMode
Nested classes/interfaces inherited from interface software.amazon.awscdk.services.cloudwatch.IAlarm
IAlarm.Jsii$Default
Nested classes/interfaces inherited from interface software.constructs.IConstruct
software.constructs.IConstruct.Jsii$Default
Nested classes/interfaces inherited from interface software.amazon.awscdk.IResource
IResource.Jsii$Default
-
Constructor Summary
ModifierConstructorDescriptionprotected
Alarm
(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) protected
Alarm
(software.amazon.jsii.JsiiObjectRef objRef) Alarm
(software.constructs.Construct scope, String id, AlarmProps props) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addAlarmAction
(@NotNull IAlarmAction... actions) Trigger this action if the alarm fires.static IAlarm
fromAlarmArn
(software.constructs.Construct scope, String id, String alarmArn) Import an existing CloudWatch alarm provided an ARN.static IAlarm
fromAlarmName
(software.constructs.Construct scope, String id, String alarmName) Import an existing CloudWatch alarm provided an Name.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, setOkActionArns
Methods inherited from class software.amazon.awscdk.Resource
applyRemovalPolicy, generatePhysicalName, getEnv, getPhysicalName, getResourceArnAttribute, getResourceNameAttribute, getStack, isOwnedResource, isResource
Methods inherited from class software.constructs.Construct
getNode, isConstruct, toString
Methods inherited from class software.amazon.jsii.JsiiObject
jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSet
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface software.constructs.IConstruct
getNode
Methods inherited from interface software.amazon.awscdk.IResource
applyRemovalPolicy, getEnv, getStack
Methods 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::invalid input: '<'account-id>:alarm:Foo). This parameter is required.
-
fromAlarmName
@Stability(Stable) @NotNull public static IAlarm fromAlarmName(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull String alarmName) Import an existing CloudWatch alarm provided an Name.- Parameters:
scope
- The parent creating construct (usuallythis
). This parameter is required.id
- The construct's name. This parameter is required.alarmName
- Alarm Name. This parameter is required.
-
addAlarmAction
Trigger this action if the alarm fires.Typically SnsAction or AutoScalingAction.
- Overrides:
addAlarmAction
in 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
AlarmWidget
can 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:
getAlarmArn
in interfaceIAlarm
- Specified by:
getAlarmArn
in classAlarmBase
-
getAlarmName
Name of this alarm.- Specified by:
getAlarmName
in interfaceIAlarm
- Specified by:
getAlarmName
in classAlarmBase
-
getMetric
The metric object this alarm was based on.
-