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

@Generated(value="jsii-pacmak/1.84.0 (build 5404dcf)", date="2023-06-19T16:29:59.690Z") @Stability(Stable) public class CfnAlarm extends CfnResource implements IInspectable
A CloudFormation AWS::Lightsail::Alarm.

The AWS::Lightsail::Alarm resource specifies an alarm that can be used to monitor a single metric for one of your Lightsail resources.

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.lightsail.*;
 CfnAlarm cfnAlarm = CfnAlarm.Builder.create(this, "MyCfnAlarm")
         .alarmName("alarmName")
         .comparisonOperator("comparisonOperator")
         .evaluationPeriods(123)
         .metricName("metricName")
         .monitoredResourceName("monitoredResourceName")
         .threshold(123)
         // the properties below are optional
         .contactProtocols(List.of("contactProtocols"))
         .datapointsToAlarm(123)
         .notificationEnabled(false)
         .notificationTriggers(List.of("notificationTriggers"))
         .treatMissingData("treatMissingData")
         .build();
 
  • 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 Construct scope, @NotNull String id, @NotNull CfnAlarmProps props)
      Create a new AWS::Lightsail::Alarm.

      Parameters:
      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.
  • 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.
    • getAttrAlarmArn

      @Stability(Stable) @NotNull public String getAttrAlarmArn()
      The Amazon Resource Name (ARN) of the alarm.
    • getAttrState

      @Stability(Stable) @NotNull public String getAttrState()
      The current state of the alarm.

      An alarm has the following possible states:

      • ALARM - The metric is outside of the defined threshold.
      • INSUFFICIENT_DATA - The alarm has recently started, the metric is not available, or not enough data is available for the metric to determine the alarm state.
      • OK - The metric is within the defined threshold.
    • getCfnProperties

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

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

      @Stability(Stable) public void setAlarmName(@NotNull String value)
      The name of the alarm.
    • 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.
    • getMetricName

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

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

      @Stability(Stable) @NotNull public String getMonitoredResourceName()
      The name of the Lightsail resource that the alarm monitors.
    • setMonitoredResourceName

      @Stability(Stable) public void setMonitoredResourceName(@NotNull String value)
      The name of the Lightsail resource that the alarm monitors.
    • getThreshold

      @Stability(Stable) @NotNull public Number getThreshold()
      The value against which the specified statistic is compared.
    • setThreshold

      @Stability(Stable) public void setThreshold(@NotNull Number value)
      The value against which the specified statistic is compared.
    • getContactProtocols

      @Stability(Stable) @Nullable public List<String> getContactProtocols()
      The contact protocols for the alarm, such as Email , SMS (text messaging), or both.

      Allowed Values : Email | SMS

    • setContactProtocols

      @Stability(Stable) public void setContactProtocols(@Nullable List<String> value)
      The contact protocols for the alarm, such as Email , SMS (text messaging), or both.

      Allowed Values : Email | SMS

    • getDatapointsToAlarm

      @Stability(Stable) @Nullable public Number getDatapointsToAlarm()
      The number of data points within the evaluation periods that must be breaching to cause the alarm to go to the ALARM state.
    • setDatapointsToAlarm

      @Stability(Stable) public void setDatapointsToAlarm(@Nullable Number value)
      The number of data points within the evaluation periods that must be breaching to cause the alarm to go to the ALARM state.
    • getNotificationEnabled

      @Stability(Stable) @Nullable public Object getNotificationEnabled()
      A Boolean value indicating whether the alarm is enabled.
    • setNotificationEnabled

      @Stability(Stable) public void setNotificationEnabled(@Nullable Boolean value)
      A Boolean value indicating whether the alarm is enabled.
    • setNotificationEnabled

      @Stability(Stable) public void setNotificationEnabled(@Nullable IResolvable value)
      A Boolean value indicating whether the alarm is enabled.
    • getNotificationTriggers

      @Stability(Stable) @Nullable public List<String> getNotificationTriggers()
      The alarm states that trigger a notification.

      To specify the OK and INSUFFICIENT_DATA values, you must also specify ContactProtocols values. Otherwise, the OK and INSUFFICIENT_DATA values will not take effect and the stack will drift.

      Allowed Values : OK | ALARM | INSUFFICIENT_DATA

    • setNotificationTriggers

      @Stability(Stable) public void setNotificationTriggers(@Nullable List<String> value)
      The alarm states that trigger a notification.

      To specify the OK and INSUFFICIENT_DATA values, you must also specify ContactProtocols values. Otherwise, the OK and INSUFFICIENT_DATA values will not take effect and the stack will drift.

      Allowed Values : OK | ALARM | INSUFFICIENT_DATA

    • getTreatMissingData

      @Stability(Stable) @Nullable public String getTreatMissingData()
      Specifies how the alarm handles missing data points.

      An alarm can treat missing data in the following ways:

      • breaching - Assumes the missing data is not within the threshold. Missing data counts towards the number of times that the metric is not within the threshold.
      • notBreaching - Assumes the missing data is within the threshold. Missing data does not count towards the number of times that the metric is not within the threshold.
      • ignore - Ignores the missing data. Maintains the current alarm state.
      • missing - Missing data is treated as missing.
    • setTreatMissingData

      @Stability(Stable) public void setTreatMissingData(@Nullable String value)
      Specifies how the alarm handles missing data points.

      An alarm can treat missing data in the following ways:

      • breaching - Assumes the missing data is not within the threshold. Missing data counts towards the number of times that the metric is not within the threshold.
      • notBreaching - Assumes the missing data is within the threshold. Missing data does not count towards the number of times that the metric is not within the threshold.
      • ignore - Ignores the missing data. Maintains the current alarm state.
      • missing - Missing data is treated as missing.