java.lang.Object
software.amazon.jsii.JsiiObject
software.constructs.Construct
All Implemented Interfaces:
IInspectable, ITaggableV2, software.amazon.jsii.JsiiSerializable, software.constructs.IConstruct, software.constructs.IDependable

@Generated(value="jsii-pacmak/1.104.0 (build e79254c)", date="2024-11-22T02:23:58.460Z") @Stability(Stable) public class CfnAlarm extends CfnResource implements IInspectable, ITaggableV2
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")
         .tags(List.of(CfnTag.builder()
                 .key("key")
                 .value("value")
                 .build()))
         .threshold(123)
         .thresholdMetricId("thresholdMetricId")
         .treatMissingData("treatMissingData")
         .unit("unit")
         .build();
 

See Also:
  • Field Details

    • CFN_RESOURCE_TYPE_NAME

      @Stability(Stable) public static final String 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

    • inspect

      @Stability(Stable) public void inspect(@NotNull TreeInspector inspector)
      Examines the CloudFormation resource and discloses attributes.

      Specified by:
      inspect in interface IInspectable
      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:
      renderProperties in class CfnResource
      Parameters:
      props - This parameter is required.
    • getAttrArn

      @Stability(Stable) @NotNull public String getAttrArn()
      The ARN of the CloudWatch alarm, such as arn:aws:cloudwatch:us-west-2:123456789012:alarm:myCloudWatchAlarm-CPUAlarm-UXMMZK36R55Z .
    • getCdkTagManager

      @Stability(Stable) @NotNull public TagManager getCdkTagManager()
      Tag Manager which manages the tags for this resource.
      Specified by:
      getCdkTagManager in interface ITaggableV2
    • getCfnProperties

      @Stability(Stable) @NotNull protected Map<String,Object> getCfnProperties()
      Overrides:
      getCfnProperties in class CfnResource
    • getComparisonOperator

      @Stability(Stable) @NotNull public String getComparisonOperator()
      The arithmetic operation to use when comparing the specified statistic and threshold.
    • setComparisonOperator

      @Stability(Stable) public void setComparisonOperator(@NotNull String value)
      The arithmetic operation to use when comparing the specified statistic and threshold.
    • getEvaluationPeriods

      @Stability(Stable) @NotNull public Number getEvaluationPeriods()
      The number of periods over which data is compared to the specified threshold.
    • setEvaluationPeriods

      @Stability(Stable) public void setEvaluationPeriods(@NotNull Number value)
      The number of periods over which data is compared to the specified threshold.
    • getActionsEnabled

      @Stability(Stable) @Nullable public Object getActionsEnabled()
      Indicates whether actions should be executed during any changes to the alarm state.
    • setActionsEnabled

      @Stability(Stable) public void setActionsEnabled(@Nullable Boolean value)
      Indicates whether actions should be executed during any changes to the alarm state.
    • setActionsEnabled

      @Stability(Stable) public void setActionsEnabled(@Nullable IResolvable value)
      Indicates whether actions should be executed during any changes to the alarm state.
    • getAlarmActions

      @Stability(Stable) @Nullable public List<String> getAlarmActions()
      The list of actions to execute when this alarm transitions into an ALARM state from any other state.
    • setAlarmActions

      @Stability(Stable) public void setAlarmActions(@Nullable List<String> value)
      The list of actions to execute when this alarm transitions into an ALARM state from any other state.
    • getAlarmDescription

      @Stability(Stable) @Nullable public String getAlarmDescription()
      The description of the alarm.
    • setAlarmDescription

      @Stability(Stable) public void setAlarmDescription(@Nullable String value)
      The description of the alarm.
    • getAlarmName

      @Stability(Stable) @Nullable public String getAlarmName()
      The name of the alarm.
    • setAlarmName

      @Stability(Stable) public void setAlarmName(@Nullable String value)
      The name of the alarm.
    • getDatapointsToAlarm

      @Stability(Stable) @Nullable public Number getDatapointsToAlarm()
      The number of datapoints that must be breaching to trigger the alarm.
    • setDatapointsToAlarm

      @Stability(Stable) public void setDatapointsToAlarm(@Nullable Number value)
      The number of datapoints that must be breaching to trigger the alarm.
    • getDimensions

      @Stability(Stable) @Nullable public Object getDimensions()
      The dimensions for the metric associated with the alarm.
    • setDimensions

      @Stability(Stable) public void setDimensions(@Nullable IResolvable value)
      The dimensions for the metric associated with the alarm.
    • setDimensions

      @Stability(Stable) public void setDimensions(@Nullable List<Object> value)
      The dimensions for the metric associated with the alarm.
    • getEvaluateLowSampleCountPercentile

      @Stability(Stable) @Nullable public String getEvaluateLowSampleCountPercentile()
      Used only for alarms based on percentiles.
    • setEvaluateLowSampleCountPercentile

      @Stability(Stable) public void setEvaluateLowSampleCountPercentile(@Nullable String value)
      Used only for alarms based on percentiles.
    • getExtendedStatistic

      @Stability(Stable) @Nullable public String getExtendedStatistic()
      The percentile statistic for the metric associated with the alarm.

      Specify a value between p0.0 and p100.

    • setExtendedStatistic

      @Stability(Stable) public void setExtendedStatistic(@Nullable String value)
      The percentile statistic for the metric associated with the alarm.

      Specify a value between p0.0 and p100.

    • getInsufficientDataActions

      @Stability(Stable) @Nullable public List<String> getInsufficientDataActions()
      The actions to execute when this alarm transitions to the INSUFFICIENT_DATA state from any other state.
    • setInsufficientDataActions

      @Stability(Stable) public void setInsufficientDataActions(@Nullable List<String> value)
      The actions to execute when this alarm transitions to the INSUFFICIENT_DATA state from any other state.
    • getMetricName

      @Stability(Stable) @Nullable public String getMetricName()
      The name of the metric associated with the alarm.
    • setMetricName

      @Stability(Stable) public void setMetricName(@Nullable String value)
      The name of the metric associated with the alarm.
    • getMetrics

      @Stability(Stable) @Nullable public Object getMetrics()
      An array that enables you to create an alarm based on the result of a metric math expression.
    • setMetrics

      @Stability(Stable) public void setMetrics(@Nullable IResolvable value)
      An array that enables you to create an alarm based on the result of a metric math expression.
    • setMetrics

      @Stability(Stable) public void setMetrics(@Nullable List<Object> value)
      An array that enables you to create an alarm based on the result of a metric math expression.
    • getNamespace

      @Stability(Stable) @Nullable public String getNamespace()
      The namespace of the metric associated with the alarm.
    • setNamespace

      @Stability(Stable) public void setNamespace(@Nullable String value)
      The namespace of the metric associated with the alarm.
    • getOkActions

      @Stability(Stable) @Nullable public List<String> getOkActions()
      The actions to execute when this alarm transitions to the OK state from any other state.
    • setOkActions

      @Stability(Stable) public void setOkActions(@Nullable List<String> value)
      The actions to execute when this alarm transitions to the OK state from any other state.
    • getPeriod

      @Stability(Stable) @Nullable public Number getPeriod()
      The period, in seconds, over which the statistic is applied.
    • setPeriod

      @Stability(Stable) public void setPeriod(@Nullable Number value)
      The period, in seconds, over which the statistic is applied.
    • getStatistic

      @Stability(Stable) @Nullable public String getStatistic()
      The statistic for the metric associated with the alarm, other than percentile.

      For percentile statistics, use ExtendedStatistic .

    • setStatistic

      @Stability(Stable) public void setStatistic(@Nullable String value)
      The statistic for the metric associated with the alarm, other than percentile.

      For percentile statistics, use ExtendedStatistic .

    • getTags

      @Stability(Stable) @Nullable public List<CfnTag> getTags()
      A list of key-value pairs to associate with the alarm.
    • setTags

      @Stability(Stable) public void setTags(@Nullable List<CfnTag> value)
      A list of key-value pairs to associate with the alarm.
    • getThreshold

      @Stability(Stable) @Nullable public Number getThreshold()
      The value to compare with the specified statistic.
    • setThreshold

      @Stability(Stable) public void setThreshold(@Nullable Number value)
      The value to compare with the specified statistic.
    • getThresholdMetricId

      @Stability(Stable) @Nullable public 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.
    • setThresholdMetricId

      @Stability(Stable) public void setThresholdMetricId(@Nullable 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.
    • getTreatMissingData

      @Stability(Stable) @Nullable public String getTreatMissingData()
      Sets how this alarm is to handle missing data points.
    • setTreatMissingData

      @Stability(Stable) public void setTreatMissingData(@Nullable String value)
      Sets how this alarm is to handle missing data points.
    • getUnit

      @Stability(Stable) @Nullable public String getUnit()
      The unit of the metric associated with the alarm.
    • setUnit

      @Stability(Stable) public void setUnit(@Nullable String value)
      The unit of the metric associated with the alarm.