@Generated(value="jsii-pacmak/1.73.0 (build 6faeda3)", date="2023-01-31T18:36:51.208Z") @Stability(value=Stable) public class CfnAlarm extends CfnResource implements IInspectable
The 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")
.threshold(123)
.thresholdMetricId("thresholdMetricId")
.treatMissingData("treatMissingData")
.unit("unit")
.build();
| Modifier and Type | Class and Description |
|---|---|
static class |
CfnAlarm.Builder
A fluent builder for
CfnAlarm. |
static interface |
CfnAlarm.DimensionProperty
Dimension is an embedded property of the `AWS::CloudWatch::Alarm` type.
|
static interface |
CfnAlarm.MetricDataQueryProperty
The `MetricDataQuery` property 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 interface |
CfnAlarm.MetricProperty
The `Metric` property type represents a specific metric.
|
static interface |
CfnAlarm.MetricStatProperty
This structure defines the metric to be returned, along with the statistics, period, and units.
|
software.amazon.jsii.JsiiObject.InitializationModeIInspectable.Jsii$Default, IInspectable.Jsii$ProxyIConstruct.Jsii$Default| Modifier and Type | Field and Description |
|---|---|
static String |
CFN_RESOURCE_TYPE_NAME
The CloudFormation resource type name for this resource class.
|
| Modifier | Constructor and Description |
|---|---|
|
CfnAlarm(Construct scope,
String id,
CfnAlarmProps props)
Create a new `AWS::CloudWatch::Alarm`.
|
protected |
CfnAlarm(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) |
protected |
CfnAlarm(software.amazon.jsii.JsiiObjectRef objRef) |
| Modifier and Type | Method and Description |
|---|---|
Object |
getActionsEnabled()
Indicates whether actions should be executed during any changes to the alarm state.
|
List<String> |
getAlarmActions()
The list of actions to execute when this alarm transitions into an ALARM state from any other state.
|
String |
getAlarmDescription()
The description of the alarm.
|
String |
getAlarmName()
The name of the alarm.
|
String |
getAttrArn()
The ARN of the CloudWatch alarm, such as `arn:aws:cloudwatch:us-west-2:123456789012:alarm:myCloudWatchAlarm-CPUAlarm-UXMMZK36R55Z` .
|
protected Map<String,Object> |
getCfnProperties() |
String |
getComparisonOperator()
The arithmetic operation to use when comparing the specified statistic and threshold.
|
Number |
getDatapointsToAlarm()
The number of datapoints that must be breaching to trigger the alarm.
|
Object |
getDimensions()
The dimensions for the metric associated with the alarm.
|
String |
getEvaluateLowSampleCountPercentile()
Used only for alarms based on percentiles.
|
Number |
getEvaluationPeriods()
The number of periods over which data is compared to the specified threshold.
|
String |
getExtendedStatistic()
The percentile statistic for the metric associated with the alarm.
|
List<String> |
getInsufficientDataActions()
The actions to execute when this alarm transitions to the `INSUFFICIENT_DATA` state from any other state.
|
String |
getMetricName()
The name of the metric associated with the alarm.
|
Object |
getMetrics()
An array that enables you to create an alarm based on the result of a metric math expression.
|
String |
getNamespace()
The namespace of the metric associated with the alarm.
|
List<String> |
getOkActions()
The actions to execute when this alarm transitions to the `OK` state from any other state.
|
Number |
getPeriod()
The period, in seconds, over which the statistic is applied.
|
String |
getStatistic()
The statistic for the metric associated with the alarm, other than percentile.
|
Number |
getThreshold()
The value to compare with the specified statistic.
|
String |
getThresholdMetricId()
In an alarm based on an anomaly detection model, this is the ID of the `ANOMALY_DETECTION_BAND` function used as the threshold for the alarm.
|
String |
getTreatMissingData()
Sets how this alarm is to handle missing data points.
|
String |
getUnit()
The unit of the metric associated with the alarm.
|
void |
inspect(TreeInspector inspector)
Examines the CloudFormation resource and discloses attributes.
|
protected Map<String,Object> |
renderProperties(Map<String,Object> props) |
void |
setActionsEnabled(Boolean value)
Indicates whether actions should be executed during any changes to the alarm state.
|
void |
setActionsEnabled(IResolvable value)
Indicates whether actions should be executed during any changes to the alarm state.
|
void |
setAlarmActions(List<String> value)
The list of actions to execute when this alarm transitions into an ALARM state from any other state.
|
void |
setAlarmDescription(String value)
The description of the alarm.
|
void |
setAlarmName(String value)
The name of the alarm.
|
void |
setComparisonOperator(String value)
The arithmetic operation to use when comparing the specified statistic and threshold.
|
void |
setDatapointsToAlarm(Number value)
The number of datapoints that must be breaching to trigger the alarm.
|
void |
setDimensions(IResolvable value)
The dimensions for the metric associated with the alarm.
|
void |
setDimensions(List<Object> value)
The dimensions for the metric associated with the alarm.
|
void |
setEvaluateLowSampleCountPercentile(String value)
Used only for alarms based on percentiles.
|
void |
setEvaluationPeriods(Number value)
The number of periods over which data is compared to the specified threshold.
|
void |
setExtendedStatistic(String value)
The percentile statistic for the metric associated with the alarm.
|
void |
setInsufficientDataActions(List<String> value)
The actions to execute when this alarm transitions to the `INSUFFICIENT_DATA` state from any other state.
|
void |
setMetricName(String value)
The name of the metric associated with the alarm.
|
void |
setMetrics(IResolvable value)
An array that enables you to create an alarm based on the result of a metric math expression.
|
void |
setMetrics(List<Object> value)
An array that enables you to create an alarm based on the result of a metric math expression.
|
void |
setNamespace(String value)
The namespace of the metric associated with the alarm.
|
void |
setOkActions(List<String> value)
The actions to execute when this alarm transitions to the `OK` state from any other state.
|
void |
setPeriod(Number value)
The period, in seconds, over which the statistic is applied.
|
void |
setStatistic(String value)
The statistic for the metric associated with the alarm, other than percentile.
|
void |
setThreshold(Number value)
The value to compare with the specified statistic.
|
void |
setThresholdMetricId(String value)
In an alarm based on an anomaly detection model, this is the ID of the `ANOMALY_DETECTION_BAND` function used as the threshold for the alarm.
|
void |
setTreatMissingData(String value)
Sets how this alarm is to handle missing data points.
|
void |
setUnit(String value)
The unit of the metric associated with the alarm.
|
addDeletionOverride, addDependsOn, addMetadata, addOverride, addPropertyDeletionOverride, addPropertyOverride, applyRemovalPolicy, applyRemovalPolicy, applyRemovalPolicy, getAtt, getCfnOptions, getCfnResourceType, getMetadata, getUpdatedProperites, isCfnResource, shouldSynthesize, toString, validatePropertiesgetRefgetCreationStack, getLogicalId, getStack, isCfnElement, overrideLogicalIdgetNode, isConstruct, onPrepare, onSynthesize, onValidate, prepare, synthesize, validatejsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSet@Stability(value=Stable) public static final String CFN_RESOURCE_TYPE_NAME
protected CfnAlarm(software.amazon.jsii.JsiiObjectRef objRef)
protected CfnAlarm(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
@Stability(value=Stable)
public CfnAlarm(@NotNull
Construct scope,
@NotNull
String id,
@NotNull
CfnAlarmProps props)
scope - - scope in which this resource is defined. This parameter is required.id - - scoped id of the resource. This parameter is required.props - - resource properties. This parameter is required.@Stability(value=Stable)
public void inspect(@NotNull
TreeInspector inspector)
inspect in interface IInspectableinspector - - tree inspector to collect and process attributes. This parameter is required.@Stability(value=Stable) @NotNull protected Map<String,Object> renderProperties(@NotNull Map<String,Object> props)
renderProperties in class CfnResourceprops - This parameter is required.@Stability(value=Stable) @NotNull public String getAttrArn()
@Stability(value=Stable) @NotNull protected Map<String,Object> getCfnProperties()
getCfnProperties in class CfnResource@Stability(value=Stable) @NotNull public String getComparisonOperator()
The specified statistic value is used as the first operand.
You can specify the following values: GreaterThanThreshold , GreaterThanOrEqualToThreshold , LessThanThreshold , or LessThanOrEqualToThreshold .
@Stability(value=Stable)
public void setComparisonOperator(@NotNull
String value)
The specified statistic value is used as the first operand.
You can specify the following values: GreaterThanThreshold , GreaterThanOrEqualToThreshold , LessThanThreshold , or LessThanOrEqualToThreshold .
@Stability(value=Stable) @NotNull public Number getEvaluationPeriods()
If you are setting an alarm that requires that a number of consecutive data points be breaching to trigger the alarm, this value specifies that number. If you are setting an "M out of N" alarm, this value is the N, and DatapointsToAlarm is the M.
For more information, see Evaluating an Alarm in the Amazon CloudWatch User Guide .
@Stability(value=Stable)
public void setEvaluationPeriods(@NotNull
Number value)
If you are setting an alarm that requires that a number of consecutive data points be breaching to trigger the alarm, this value specifies that number. If you are setting an "M out of N" alarm, this value is the N, and DatapointsToAlarm is the M.
For more information, see Evaluating an Alarm in the Amazon CloudWatch User Guide .
@Stability(value=Stable) @Nullable public Object getActionsEnabled()
The default is TRUE.
@Stability(value=Stable)
public void setActionsEnabled(@Nullable
Boolean value)
The default is TRUE.
@Stability(value=Stable)
public void setActionsEnabled(@Nullable
IResolvable value)
The default is TRUE.
@Stability(value=Stable) @Nullable public List<String> getAlarmActions()
Specify each action as an Amazon Resource Name (ARN). For more information about creating alarms and the actions that you can specify, see PutMetricAlarm in the Amazon CloudWatch API Reference .
@Stability(value=Stable)
public void setAlarmActions(@Nullable
List<String> value)
Specify each action as an Amazon Resource Name (ARN). For more information about creating alarms and the actions that you can specify, see PutMetricAlarm in the Amazon CloudWatch API Reference .
@Stability(value=Stable) @Nullable public String getAlarmDescription()
@Stability(value=Stable)
public void setAlarmDescription(@Nullable
String value)
@Stability(value=Stable) @Nullable public String getAlarmName()
If you don't specify a name, AWS CloudFormation generates a unique physical ID and uses that ID for the alarm name.
If you specify a name, you cannot perform updates that require replacement of this resource. You can perform updates that require no or some interruption. If you must replace the resource, specify a new name.
@Stability(value=Stable)
public void setAlarmName(@Nullable
String value)
If you don't specify a name, AWS CloudFormation generates a unique physical ID and uses that ID for the alarm name.
If you specify a name, you cannot perform updates that require replacement of this resource. You can perform updates that require no or some interruption. If you must replace the resource, specify a new name.
@Stability(value=Stable) @Nullable public Number getDatapointsToAlarm()
This is used only if you are setting an "M out of N" alarm. In that case, this value is the M, and the value that you set for EvaluationPeriods is the N value. For more information, see Evaluating an Alarm in the Amazon CloudWatch User Guide .
If you omit this parameter, CloudWatch uses the same value here that you set for EvaluationPeriods , and the alarm goes to alarm state if that many consecutive periods are breaching.
@Stability(value=Stable)
public void setDatapointsToAlarm(@Nullable
Number value)
This is used only if you are setting an "M out of N" alarm. In that case, this value is the M, and the value that you set for EvaluationPeriods is the N value. For more information, see Evaluating an Alarm in the Amazon CloudWatch User Guide .
If you omit this parameter, CloudWatch uses the same value here that you set for EvaluationPeriods , and the alarm goes to alarm state if that many consecutive periods are breaching.
@Stability(value=Stable) @Nullable public Object getDimensions()
For an alarm based on a math expression, you can't specify Dimensions . Instead, you use Metrics .
@Stability(value=Stable)
public void setDimensions(@Nullable
IResolvable value)
For an alarm based on a math expression, you can't specify Dimensions . Instead, you use Metrics .
@Stability(value=Stable)
public void setDimensions(@Nullable
List<Object> value)
For an alarm based on a math expression, you can't specify Dimensions . Instead, you use Metrics .
@Stability(value=Stable) @Nullable public String getEvaluateLowSampleCountPercentile()
If ignore , the alarm state does not change during periods with too few data points to be statistically significant. If evaluate or this parameter is not used, the alarm is always evaluated and possibly changes state no matter how many data points are available.
@Stability(value=Stable)
public void setEvaluateLowSampleCountPercentile(@Nullable
String value)
If ignore , the alarm state does not change during periods with too few data points to be statistically significant. If evaluate or this parameter is not used, the alarm is always evaluated and possibly changes state no matter how many data points are available.
@Stability(value=Stable) @Nullable public String getExtendedStatistic()
For an alarm based on a metric, you must specify either Statistic or ExtendedStatistic but not both.
For an alarm based on a math expression, you can't specify ExtendedStatistic . Instead, you use Metrics .
@Stability(value=Stable)
public void setExtendedStatistic(@Nullable
String value)
For an alarm based on a metric, you must specify either Statistic or ExtendedStatistic but not both.
For an alarm based on a math expression, you can't specify ExtendedStatistic . Instead, you use Metrics .
@Stability(value=Stable) @Nullable public List<String> getInsufficientDataActions()
Each action is specified as an Amazon Resource Name (ARN).
@Stability(value=Stable)
public void setInsufficientDataActions(@Nullable
List<String> value)
Each action is specified as an Amazon Resource Name (ARN).
@Stability(value=Stable) @Nullable public String getMetricName()
This is required for an alarm based on a metric. For an alarm based on a math expression, you use Metrics instead and you can't specify MetricName .
@Stability(value=Stable)
public void setMetricName(@Nullable
String value)
This is required for an alarm based on a metric. For an alarm based on a math expression, you use Metrics instead and you can't specify MetricName .
@Stability(value=Stable) @Nullable public Object getMetrics()
Each item in the array either retrieves a metric or performs a math expression.
If you specify the Metrics parameter, you cannot specify MetricName , Dimensions , Period , Namespace , Statistic , ExtendedStatistic , or Unit .
@Stability(value=Stable)
public void setMetrics(@Nullable
IResolvable value)
Each item in the array either retrieves a metric or performs a math expression.
If you specify the Metrics parameter, you cannot specify MetricName , Dimensions , Period , Namespace , Statistic , ExtendedStatistic , or Unit .
@Stability(value=Stable)
public void setMetrics(@Nullable
List<Object> value)
Each item in the array either retrieves a metric or performs a math expression.
If you specify the Metrics parameter, you cannot specify MetricName , Dimensions , Period , Namespace , Statistic , ExtendedStatistic , or Unit .
@Stability(value=Stable) @Nullable public String getNamespace()
This is required for an alarm based on a metric. For an alarm based on a math expression, you can't specify Namespace and you use Metrics instead.
For a list of namespaces for metrics from AWS services, see AWS Services That Publish CloudWatch Metrics.
@Stability(value=Stable)
public void setNamespace(@Nullable
String value)
This is required for an alarm based on a metric. For an alarm based on a math expression, you can't specify Namespace and you use Metrics instead.
For a list of namespaces for metrics from AWS services, see AWS Services That Publish CloudWatch Metrics.
@Stability(value=Stable) @Nullable public List<String> getOkActions()
Each action is specified as an Amazon Resource Name (ARN).
@Stability(value=Stable)
public void setOkActions(@Nullable
List<String> value)
Each action is specified as an Amazon Resource Name (ARN).
@Stability(value=Stable) @Nullable public Number getPeriod()
This is required for an alarm based on a metric. Valid values are 10, 30, 60, and any multiple of 60.
For an alarm based on a math expression, you can't specify Period , and instead you use the Metrics parameter.
Minimum: 10
@Stability(value=Stable)
public void setPeriod(@Nullable
Number value)
This is required for an alarm based on a metric. Valid values are 10, 30, 60, and any multiple of 60.
For an alarm based on a math expression, you can't specify Period , and instead you use the Metrics parameter.
Minimum: 10
@Stability(value=Stable) @Nullable public String getStatistic()
For an alarm based on a metric, you must specify either Statistic or ExtendedStatistic but not both.
For an alarm based on a math expression, you can't specify Statistic . Instead, you use Metrics .
@Stability(value=Stable)
public void setStatistic(@Nullable
String value)
For an alarm based on a metric, you must specify either Statistic or ExtendedStatistic but not both.
For an alarm based on a math expression, you can't specify Statistic . Instead, you use Metrics .
@Stability(value=Stable) @Nullable public Number getThreshold()
@Stability(value=Stable)
public void setThreshold(@Nullable
Number value)
@Stability(value=Stable) @Nullable public String getThresholdMetricId()
@Stability(value=Stable)
public void setThresholdMetricId(@Nullable
String value)
@Stability(value=Stable) @Nullable public String getTreatMissingData()
Valid values are breaching , notBreaching , ignore , and missing . For more information, see Configuring How CloudWatch Alarms Treat Missing Data in the Amazon CloudWatch User Guide .
If you omit this parameter, the default behavior of missing is used.
@Stability(value=Stable)
public void setTreatMissingData(@Nullable
String value)
Valid values are breaching , notBreaching , ignore , and missing . For more information, see Configuring How CloudWatch Alarms Treat Missing Data in the Amazon CloudWatch User Guide .
If you omit this parameter, the default behavior of missing is used.
@Stability(value=Stable) @Nullable public String getUnit()
Specify this only if you are creating an alarm based on a single metric. Do not specify this if you are specifying a Metrics array.
You can specify the following values: Seconds, Microseconds, Milliseconds, Bytes, Kilobytes, Megabytes, Gigabytes, Terabytes, Bits, Kilobits, Megabits, Gigabits, Terabits, Percent, Count, Bytes/Second, Kilobytes/Second, Megabytes/Second, Gigabytes/Second, Terabytes/Second, Bits/Second, Kilobits/Second, Megabits/Second, Gigabits/Second, Terabits/Second, Count/Second, or None.
@Stability(value=Stable)
public void setUnit(@Nullable
String value)
Specify this only if you are creating an alarm based on a single metric. Do not specify this if you are specifying a Metrics array.
You can specify the following values: Seconds, Microseconds, Milliseconds, Bytes, Kilobytes, Megabytes, Gigabytes, Terabytes, Bits, Kilobits, Megabits, Gigabits, Terabits, Percent, Count, Bytes/Second, Kilobytes/Second, Megabytes/Second, Gigabytes/Second, Terabytes/Second, Bits/Second, Kilobits/Second, Megabits/Second, Gigabits/Second, Terabits/Second, Count/Second, or None.
Copyright © 2023. All rights reserved.