Interface AnomalyDetectionAlarmProps

All Superinterfaces:
software.amazon.jsii.JsiiSerializable
All Known Implementing Classes:
AnomalyDetectionAlarmProps.Jsii$Proxy

@Generated(value="jsii-pacmak/1.112.0 (build de1bc80)", date="2025-07-24T11:33:10.714Z") @Stability(Stable) public interface AnomalyDetectionAlarmProps extends software.amazon.jsii.JsiiSerializable
Properties for Anomaly Detection Alarms.

Example:

 // Create a metric
 Metric metric = Metric.Builder.create()
         .namespace("AWS/EC2")
         .metricName("CPUUtilization")
         .statistic("Average")
         .period(Duration.minutes(5))
         .build();
 // Create an anomaly detection alarm
 AnomalyDetectionAlarm alarm = AnomalyDetectionAlarm.Builder.create(this, "AnomalyAlarm")
         .metric(metric)
         .evaluationPeriods(1)
         // Number of standard deviations for the band (default: 2)
         .stdDevs(2)
         // Alarm outside on either side of the band, or just below or above it (default: outside)
         .comparisonOperator(ComparisonOperator.LESS_THAN_LOWER_OR_GREATER_THAN_UPPER_THRESHOLD)
         .alarmDescription("Alarm when metric is outside the expected band")
         .build();
 
  • Method Details

    • getEvaluationPeriods

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

      @Stability(Stable) @NotNull IMetric getMetric()
      The metric to add the alarm on.

      Metric objects can be obtained from most resources, or you can construct custom Metric objects by instantiating one.

    • getActionsEnabled

      @Stability(Stable) @Nullable default Boolean getActionsEnabled()
      Whether the actions for this alarm are enabled.

      Default: true

    • getAlarmDescription

      @Stability(Stable) @Nullable default String getAlarmDescription()
      Description for the alarm.

      Default: No description

    • getAlarmName

      @Stability(Stable) @Nullable default String getAlarmName()
      Name of the alarm.

      Default: Automatically generated name

    • getComparisonOperator

      @Stability(Stable) @Nullable default ComparisonOperator getComparisonOperator()
      Comparison operator to use to check if metric is breaching.

      Must be one of the anomaly detection operators:

      • LESS_THAN_LOWER_OR_GREATER_THAN_UPPER_THRESHOLD
      • GREATER_THAN_UPPER_THRESHOLD
      • LESS_THAN_LOWER_THRESHOLD

      Default: LESS_THAN_LOWER_OR_GREATER_THAN_UPPER_THRESHOLD

    • getDatapointsToAlarm

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

      This is used only if you are setting an "M out of N" alarm. In that case, this value is the M. For more information, see Evaluating an Alarm in the Amazon CloudWatch User Guide.

      Default: ``evaluationPeriods``

      See Also:
    • getEvaluateLowSampleCountPercentile

      @Stability(Stable) @Nullable default String getEvaluateLowSampleCountPercentile()
      Specifies whether to evaluate the data and potentially change the alarm state if there are too few data points to be statistically significant.

      Used only for alarms that are based on percentiles.

      Default: - Not configured.

    • getPeriod

      @Stability(Deprecated) @Deprecated @Nullable default Duration getPeriod()
      Deprecated.
      Use metric.with({ period: ... }) to encode the period into the Metric object
      (deprecated) The period over which the specified statistic is applied.

      Cannot be used with MathExpression objects.

      Default: - The period from the metric

    • getStatistic

      @Stability(Deprecated) @Deprecated @Nullable default String getStatistic()
      Deprecated.
      Use metric.with({ statistic: ... }) to encode the period into the Metric object
      (deprecated) What function to use for aggregating.

      Can be one of the following:

      • "Minimum" | "min"
      • "Maximum" | "max"
      • "Average" | "avg"
      • "Sum" | "sum"
      • "SampleCount | "n"
      • "pNN.NN"

      Cannot be used with MathExpression objects.

      Default: - The statistic from the metric

    • getStdDevs

      @Stability(Stable) @Nullable default Number getStdDevs()
      The number of standard deviations to use for the anomaly detection band.

      The higher the value, the wider the band.

      • Must be greater than 0. A value of 0 or negative values would not make sense in the context of calculating standard deviations.
      • There is no strict maximum value defined, as standard deviations can theoretically extend infinitely. However, in practice, values beyond 5 or 6 standard deviations are rarely used, as they would result in an extremely wide anomaly detection band, potentially missing significant anomalies.

      Default: 2

    • getTreatMissingData

      @Stability(Stable) @Nullable default TreatMissingData getTreatMissingData()
      Sets how this alarm is to handle missing data points.

      Default: TreatMissingData.Missing

    • builder

      @Stability(Stable) static AnomalyDetectionAlarmProps.Builder builder()
      Returns:
      a AnomalyDetectionAlarmProps.Builder of AnomalyDetectionAlarmProps