Class CfnAlarm
- All Implemented Interfaces:
IEnvironmentAware,IInspectable,ITaggableV2,IAlarmRef,software.amazon.jsii.JsiiSerializable,software.constructs.IConstruct,software.constructs.IDependable
AWS::CloudWatch::Alarm type specifies an alarm and associates it with the specified metric or metric math expression.
When this operation creates an alarm, the alarm state is immediately set to INSUFFICIENT_DATA . The alarm is then evaluated and its state is set appropriately. Any actions associated with the new state are then executed.
When you update an existing alarm, its state is left unchanged, but the update completely overwrites the previous configuration of the alarm.
Example:
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.services.cloudwatch.*;
CfnAlarm cfnAlarm = CfnAlarm.Builder.create(this, "MyCfnAlarm")
.comparisonOperator("comparisonOperator")
.evaluationPeriods(123)
// the properties below are optional
.actionsEnabled(false)
.alarmActions(List.of("alarmActions"))
.alarmDescription("alarmDescription")
.alarmName("alarmName")
.datapointsToAlarm(123)
.dimensions(List.of(DimensionProperty.builder()
.name("name")
.value("value")
.build()))
.evaluateLowSampleCountPercentile("evaluateLowSampleCountPercentile")
.extendedStatistic("extendedStatistic")
.insufficientDataActions(List.of("insufficientDataActions"))
.metricName("metricName")
.metrics(List.of(MetricDataQueryProperty.builder()
.id("id")
// the properties below are optional
.accountId("accountId")
.expression("expression")
.label("label")
.metricStat(MetricStatProperty.builder()
.metric(MetricProperty.builder()
.dimensions(List.of(DimensionProperty.builder()
.name("name")
.value("value")
.build()))
.metricName("metricName")
.namespace("namespace")
.build())
.period(123)
.stat("stat")
// the properties below are optional
.unit("unit")
.build())
.period(123)
.returnData(false)
.build()))
.namespace("namespace")
.okActions(List.of("okActions"))
.period(123)
.statistic("statistic")
.tags(List.of(CfnTag.builder()
.key("key")
.value("value")
.build()))
.threshold(123)
.thresholdMetricId("thresholdMetricId")
.treatMissingData("treatMissingData")
.unit("unit")
.build();
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classA fluent builder forCfnAlarm.static interfaceDimension is an embedded property of theAWS::CloudWatch::Alarmtype.static interfaceTheMetricDataQueryproperty type specifies the metric data to return, and whether this call is just retrieving a batch set of data for one metric, or is performing a math expression on metric data.static interfaceTheMetricproperty type represents a specific metric.static interfaceThis structure defines the metric to be returned, along with the statistics, period, and units.Nested classes/interfaces inherited from class software.amazon.jsii.JsiiObject
software.amazon.jsii.JsiiObject.InitializationModeNested classes/interfaces inherited from interface software.amazon.awscdk.services.cloudwatch.IAlarmRef
IAlarmRef.Jsii$Default, IAlarmRef.Jsii$ProxyNested classes/interfaces inherited from interface software.constructs.IConstruct
software.constructs.IConstruct.Jsii$DefaultNested classes/interfaces inherited from interface software.amazon.awscdk.IInspectable
IInspectable.Jsii$Default, IInspectable.Jsii$ProxyNested classes/interfaces inherited from interface software.amazon.awscdk.ITaggableV2
ITaggableV2.Jsii$Default, ITaggableV2.Jsii$Proxy -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe CloudFormation resource type name for this resource class. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCfnAlarm(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) protectedCfnAlarm(software.amazon.jsii.JsiiObjectRef objRef) CfnAlarm(software.constructs.Construct scope, String id, CfnAlarmProps props) -
Method Summary
Modifier and TypeMethodDescriptionstatic IAlarmReffromAlarmArn(software.constructs.Construct scope, String id, String arn) Creates a new IAlarmRef from an ARN.static IAlarmReffromAlarmName(software.constructs.Construct scope, String id, String alarmName) Creates a new IAlarmRef from a alarmName.Indicates whether actions should be executed during any changes to the alarm state.The list of actions to execute when this alarm transitions into an ALARM state from any other state.The description of the alarm.The name of the alarm.A reference to a Alarm resource.The ARN of the CloudWatch alarm, such asarn:aws:cloudwatch:us-west-2:123456789012:alarm:myCloudWatchAlarm-CPUAlarm-UXMMZK36R55Z.Tag Manager which manages the tags for this resource.The arithmetic operation to use when comparing the specified statistic and threshold.The number of datapoints that must be breaching to trigger the alarm.The dimensions for the metric associated with the alarm.Used only for alarms based on percentiles.The number of periods over which data is compared to the specified threshold.The percentile statistic for the metric associated with the alarm.The actions to execute when this alarm transitions to theINSUFFICIENT_DATAstate from any other state.The name of the metric associated with the alarm.An array that enables you to create an alarm based on the result of a metric math expression.The namespace of the metric associated with the alarm.The actions to execute when this alarm transitions to theOKstate from any other state.The period, in seconds, over which the statistic is applied.The statistic for the metric associated with the alarm, other than percentile.getTags()A list of key-value pairs to associate with the alarm.The value to compare with the specified statistic.In an alarm based on an anomaly detection model, this is the ID of theANOMALY_DETECTION_BANDfunction used as the threshold for the alarm.Sets how this alarm is to handle missing data points.getUnit()The unit of the metric associated with the alarm.voidinspect(TreeInspector inspector) Examines the CloudFormation resource and discloses attributes.renderProperties(Map<String, Object> props) voidsetActionsEnabled(Boolean value) Indicates whether actions should be executed during any changes to the alarm state.voidsetActionsEnabled(IResolvable value) Indicates whether actions should be executed during any changes to the alarm state.voidsetAlarmActions(List<String> value) The list of actions to execute when this alarm transitions into an ALARM state from any other state.voidsetAlarmDescription(String value) The description of the alarm.voidsetAlarmName(String value) The name of the alarm.voidsetComparisonOperator(String value) The arithmetic operation to use when comparing the specified statistic and threshold.voidsetDatapointsToAlarm(Number value) The number of datapoints that must be breaching to trigger the alarm.voidsetDimensions(List<Object> value) The dimensions for the metric associated with the alarm.voidsetDimensions(IResolvable value) The dimensions for the metric associated with the alarm.voidUsed only for alarms based on percentiles.voidsetEvaluationPeriods(Number value) The number of periods over which data is compared to the specified threshold.voidsetExtendedStatistic(String value) The percentile statistic for the metric associated with the alarm.voidsetInsufficientDataActions(List<String> value) The actions to execute when this alarm transitions to theINSUFFICIENT_DATAstate from any other state.voidsetMetricName(String value) The name of the metric associated with the alarm.voidsetMetrics(List<Object> value) An array that enables you to create an alarm based on the result of a metric math expression.voidsetMetrics(IResolvable value) An array that enables you to create an alarm based on the result of a metric math expression.voidsetNamespace(String value) The namespace of the metric associated with the alarm.voidsetOkActions(List<String> value) The actions to execute when this alarm transitions to theOKstate from any other state.voidThe period, in seconds, over which the statistic is applied.voidsetStatistic(String value) The statistic for the metric associated with the alarm, other than percentile.voidA list of key-value pairs to associate with the alarm.voidsetThreshold(Number value) The value to compare with the specified statistic.voidsetThresholdMetricId(String value) In an alarm based on an anomaly detection model, this is the ID of theANOMALY_DETECTION_BANDfunction used as the threshold for the alarm.voidsetTreatMissingData(String value) Sets how this alarm is to handle missing data points.voidThe unit of the metric associated with the alarm.Methods inherited from class software.amazon.awscdk.CfnResource
addDeletionOverride, addDependency, addDependsOn, addMetadata, addOverride, addPropertyDeletionOverride, addPropertyOverride, applyRemovalPolicy, applyRemovalPolicy, applyRemovalPolicy, getAtt, getAtt, getCfnOptions, getCfnResourceType, getEnv, getMetadata, getUpdatedProperites, getUpdatedProperties, isCfnResource, obtainDependencies, obtainResourceDependencies, removeDependency, replaceDependency, shouldSynthesize, toString, validatePropertiesMethods inherited from class software.amazon.awscdk.CfnRefElement
getRefMethods inherited from class software.amazon.awscdk.CfnElement
getCreationStack, getLogicalId, getStack, isCfnElement, overrideLogicalIdMethods inherited from class software.constructs.Construct
getNode, isConstructMethods 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.constructs.IConstruct
getNodeMethods inherited from interface software.amazon.awscdk.IEnvironmentAware
getEnvMethods inherited from interface software.amazon.jsii.JsiiSerializable
$jsii$toJson
-
Field Details
-
CFN_RESOURCE_TYPE_NAME
The CloudFormation resource type name for this resource class.
-
-
Constructor Details
-
CfnAlarm
protected CfnAlarm(software.amazon.jsii.JsiiObjectRef objRef) -
CfnAlarm
protected CfnAlarm(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) -
CfnAlarm
@Stability(Stable) public CfnAlarm(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull CfnAlarmProps props) - Parameters:
scope- Scope in which this resource is defined. This parameter is required.id- Construct identifier for this resource (unique in its scope). This parameter is required.props- Resource properties. This parameter is required.
-
-
Method Details
-
fromAlarmArn
@Stability(Stable) @NotNull public static IAlarmRef fromAlarmArn(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull String arn) Creates a new IAlarmRef from an ARN.- Parameters:
scope- This parameter is required.id- This parameter is required.arn- This parameter is required.
-
fromAlarmName
@Stability(Stable) @NotNull public static IAlarmRef fromAlarmName(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull String alarmName) Creates a new IAlarmRef from a alarmName.- Parameters:
scope- This parameter is required.id- This parameter is required.alarmName- This parameter is required.
-
inspect
Examines the CloudFormation resource and discloses attributes.- Specified by:
inspectin interfaceIInspectable- Parameters:
inspector- tree inspector to collect and process attributes. This parameter is required.
-
renderProperties
@Stability(Stable) @NotNull protected Map<String,Object> renderProperties(@NotNull Map<String, Object> props) - Overrides:
renderPropertiesin classCfnResource- Parameters:
props- This parameter is required.
-
getAlarmRef
A reference to a Alarm resource.- Specified by:
getAlarmRefin interfaceIAlarmRef
-
getAttrArn
The ARN of the CloudWatch alarm, such asarn:aws:cloudwatch:us-west-2:123456789012:alarm:myCloudWatchAlarm-CPUAlarm-UXMMZK36R55Z. -
getCdkTagManager
Tag Manager which manages the tags for this resource.- Specified by:
getCdkTagManagerin interfaceITaggableV2
-
getCfnProperties
- Overrides:
getCfnPropertiesin classCfnResource
-
getComparisonOperator
The arithmetic operation to use when comparing the specified statistic and threshold. -
setComparisonOperator
The arithmetic operation to use when comparing the specified statistic and threshold. -
getEvaluationPeriods
The number of periods over which data is compared to the specified threshold. -
setEvaluationPeriods
The number of periods over which data is compared to the specified threshold. -
getActionsEnabled
Indicates whether actions should be executed during any changes to the alarm state.Returns union: either
BooleanorIResolvable -
setActionsEnabled
Indicates whether actions should be executed during any changes to the alarm state. -
setActionsEnabled
Indicates whether actions should be executed during any changes to the alarm state. -
getAlarmActions
The list of actions to execute when this alarm transitions into an ALARM state from any other state. -
setAlarmActions
The list of actions to execute when this alarm transitions into an ALARM state from any other state. -
getAlarmDescription
The description of the alarm. -
setAlarmDescription
The description of the alarm. -
getAlarmName
The name of the alarm. -
setAlarmName
The name of the alarm. -
getDatapointsToAlarm
The number of datapoints that must be breaching to trigger the alarm. -
setDatapointsToAlarm
The number of datapoints that must be breaching to trigger the alarm. -
getDimensions
The dimensions for the metric associated with the alarm.Returns union: either
IResolvableor Listinvalid input: '<'eitherIResolvableorCfnAlarm.DimensionProperty> -
setDimensions
The dimensions for the metric associated with the alarm. -
setDimensions
The dimensions for the metric associated with the alarm. -
getEvaluateLowSampleCountPercentile
Used only for alarms based on percentiles. -
setEvaluateLowSampleCountPercentile
Used only for alarms based on percentiles. -
getExtendedStatistic
The percentile statistic for the metric associated with the alarm.Specify a value between p0.0 and p100.
-
setExtendedStatistic
The percentile statistic for the metric associated with the alarm.Specify a value between p0.0 and p100.
-
getInsufficientDataActions
The actions to execute when this alarm transitions to theINSUFFICIENT_DATAstate from any other state. -
setInsufficientDataActions
The actions to execute when this alarm transitions to theINSUFFICIENT_DATAstate from any other state. -
getMetricName
The name of the metric associated with the alarm. -
setMetricName
The name of the metric associated with the alarm. -
getMetrics
An array that enables you to create an alarm based on the result of a metric math expression.Returns union: either
IResolvableor Listinvalid input: '<'eitherIResolvableorCfnAlarm.MetricDataQueryProperty> -
setMetrics
An array that enables you to create an alarm based on the result of a metric math expression. -
setMetrics
An array that enables you to create an alarm based on the result of a metric math expression. -
getNamespace
The namespace of the metric associated with the alarm. -
setNamespace
The namespace of the metric associated with the alarm. -
getOkActions
The actions to execute when this alarm transitions to theOKstate from any other state. -
setOkActions
The actions to execute when this alarm transitions to theOKstate from any other state. -
getPeriod
The period, in seconds, over which the statistic is applied. -
setPeriod
The period, in seconds, over which the statistic is applied. -
getStatistic
The statistic for the metric associated with the alarm, other than percentile.For percentile statistics, use
ExtendedStatistic. -
setStatistic
The statistic for the metric associated with the alarm, other than percentile.For percentile statistics, use
ExtendedStatistic. -
getTags
A list of key-value pairs to associate with the alarm. -
setTags
A list of key-value pairs to associate with the alarm. -
getThreshold
The value to compare with the specified statistic. -
setThreshold
The value to compare with the specified statistic. -
getThresholdMetricId
In an alarm based on an anomaly detection model, this is the ID of theANOMALY_DETECTION_BANDfunction used as the threshold for the alarm. -
setThresholdMetricId
In an alarm based on an anomaly detection model, this is the ID of theANOMALY_DETECTION_BANDfunction used as the threshold for the alarm. -
getTreatMissingData
Sets how this alarm is to handle missing data points. -
setTreatMissingData
Sets how this alarm is to handle missing data points. -
getUnit
The unit of the metric associated with the alarm. -
setUnit
The unit of the metric associated with the alarm.
-