CfnAlarmProps

class aws_cdk.aws_cloudwatch.CfnAlarmProps(*, comparison_operator, evaluation_periods, actions_enabled=None, alarm_actions=None, alarm_description=None, alarm_name=None, datapoints_to_alarm=None, dimensions=None, evaluate_low_sample_count_percentile=None, extended_statistic=None, insufficient_data_actions=None, metric_name=None, metrics=None, namespace=None, ok_actions=None, period=None, statistic=None, threshold=None, threshold_metric_id=None, treat_missing_data=None, unit=None)

Bases: object

Properties for defining a CfnAlarm.

Parameters
  • comparison_operator (str) – The arithmetic operation to use when comparing the specified statistic and threshold. The specified statistic value is used as the first operand. You can specify the following values: GreaterThanThreshold , GreaterThanOrEqualToThreshold , LessThanThreshold , or LessThanOrEqualToThreshold .

  • evaluation_periods (Union[int, float]) – The number of periods over which data is compared to the specified threshold. 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 .

  • actions_enabled (Union[bool, IResolvable, None]) – Indicates whether actions should be executed during any changes to the alarm state. The default is TRUE.

  • alarm_actions (Optional[Sequence[str]]) – The list of actions to execute when this alarm transitions into an ALARM state from any other state. 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 .

  • alarm_description (Optional[str]) – The description of the alarm.

  • alarm_name (Optional[str]) – The name of the alarm. If you don’t specify a name, AWS CloudFormation generates a unique physical ID and uses that ID for the alarm name. .. epigraph:: 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.

  • datapoints_to_alarm (Union[int, float, None]) –

    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, 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.

  • dimensions (Union[IResolvable, Sequence[Union[IResolvable, DimensionProperty, Dict[str, Any]]], None]) – The dimensions for the metric associated with the alarm. For an alarm based on a math expression, you can’t specify Dimensions . Instead, you use Metrics .

  • evaluate_low_sample_count_percentile (Optional[str]) – Used only for alarms based on percentiles. 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.

  • extended_statistic (Optional[str]) – The percentile statistic for the metric associated with the alarm. Specify a value between p0.0 and p100. 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 .

  • insufficient_data_actions (Optional[Sequence[str]]) – The actions to execute when this alarm transitions to the INSUFFICIENT_DATA state from any other state. Each action is specified as an Amazon Resource Name (ARN).

  • metric_name (Optional[str]) – The name of the metric associated with the alarm. 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 .

  • metrics (Union[IResolvable, Sequence[Union[IResolvable, MetricDataQueryProperty, Dict[str, Any]]], None]) – An array that enables you to create an alarm based on the result of a metric math expression. 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 .

  • namespace (Optional[str]) – The namespace of the metric associated with the alarm. 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.

  • ok_actions (Optional[Sequence[str]]) – The actions to execute when this alarm transitions to the OK state from any other state. Each action is specified as an Amazon Resource Name (ARN).

  • period (Union[int, float, None]) – The period, in seconds, over which the statistic is applied. 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

  • statistic (Optional[str]) – The statistic for the metric associated with the alarm, other than percentile. For percentile statistics, use ExtendedStatistic . 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 .

  • threshold (Union[int, float, None]) – The value to compare with the specified statistic.

  • threshold_metric_id (Optional[str]) – 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.

  • treat_missing_data (Optional[str]) – Sets how this alarm is to handle missing data points. 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.

  • unit (Optional[str]) – The unit of the metric associated with the alarm. 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.

Link

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cw-alarm.html

ExampleMetadata

fixture=_generated

Example:

# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
import aws_cdk.aws_cloudwatch as cloudwatch

cfn_alarm_props = cloudwatch.CfnAlarmProps(
    comparison_operator="comparisonOperator",
    evaluation_periods=123,

    # the properties below are optional
    actions_enabled=False,
    alarm_actions=["alarmActions"],
    alarm_description="alarmDescription",
    alarm_name="alarmName",
    datapoints_to_alarm=123,
    dimensions=[cloudwatch.CfnAlarm.DimensionProperty(
        name="name",
        value="value"
    )],
    evaluate_low_sample_count_percentile="evaluateLowSampleCountPercentile",
    extended_statistic="extendedStatistic",
    insufficient_data_actions=["insufficientDataActions"],
    metric_name="metricName",
    metrics=[cloudwatch.CfnAlarm.MetricDataQueryProperty(
        id="id",

        # the properties below are optional
        account_id="accountId",
        expression="expression",
        label="label",
        metric_stat=cloudwatch.CfnAlarm.MetricStatProperty(
            metric=cloudwatch.CfnAlarm.MetricProperty(
                dimensions=[cloudwatch.CfnAlarm.DimensionProperty(
                    name="name",
                    value="value"
                )],
                metric_name="metricName",
                namespace="namespace"
            ),
            period=123,
            stat="stat",

            # the properties below are optional
            unit="unit"
        ),
        period=123,
        return_data=False
    )],
    namespace="namespace",
    ok_actions=["okActions"],
    period=123,
    statistic="statistic",
    threshold=123,
    threshold_metric_id="thresholdMetricId",
    treat_missing_data="treatMissingData",
    unit="unit"
)

Attributes

actions_enabled

Indicates whether actions should be executed during any changes to the alarm state.

The default is TRUE.

Link

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cw-alarm.html#cfn-cloudwatch-alarms-actionsenabled

Return type

Union[bool, IResolvable, None]

alarm_actions

The list of actions to execute when this alarm transitions into an ALARM state from any other state.

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 .

Link

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cw-alarm.html#cfn-cloudwatch-alarms-alarmactions

Return type

Optional[List[str]]

alarm_description

The description of the alarm.

Link

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cw-alarm.html#cfn-cloudwatch-alarms-alarmdescription

Return type

Optional[str]

alarm_name

The name of the alarm.

If you don’t specify a name, AWS CloudFormation generates a unique physical ID and uses that ID for the alarm name. .. epigraph:

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.
Link

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cw-alarm.html#cfn-cloudwatch-alarms-alarmname

Return type

Optional[str]

comparison_operator

The arithmetic operation to use when comparing the specified statistic and threshold.

The specified statistic value is used as the first operand.

You can specify the following values: GreaterThanThreshold , GreaterThanOrEqualToThreshold , LessThanThreshold , or LessThanOrEqualToThreshold .

Link

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cw-alarm.html#cfn-cloudwatch-alarms-comparisonoperator

Return type

str

datapoints_to_alarm

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, 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.

Link

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cw-alarm.html#cfn-cloudwatch-alarm-datapointstoalarm

Return type

Union[int, float, None]

dimensions

The dimensions for the metric associated with the alarm.

For an alarm based on a math expression, you can’t specify Dimensions . Instead, you use Metrics .

Link

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cw-alarm.html#cfn-cloudwatch-alarms-dimension

Return type

Union[IResolvable, List[Union[IResolvable, DimensionProperty]], None]

evaluate_low_sample_count_percentile

Used only for alarms based on percentiles.

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.

Link

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cw-alarm.html#cfn-cloudwatch-alarms-evaluatelowsamplecountpercentile

Return type

Optional[str]

evaluation_periods

The number of periods over which data is compared to the specified threshold.

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 .

Link

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cw-alarm.html#cfn-cloudwatch-alarms-evaluationperiods

Return type

Union[int, float]

extended_statistic

The percentile statistic for the metric associated with the alarm. Specify a value between p0.0 and p100.

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 .

Link

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cw-alarm.html#cfn-cloudwatch-alarms-extendedstatistic

Return type

Optional[str]

insufficient_data_actions

The actions to execute when this alarm transitions to the INSUFFICIENT_DATA state from any other state.

Each action is specified as an Amazon Resource Name (ARN).

Link

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cw-alarm.html#cfn-cloudwatch-alarms-insufficientdataactions

Return type

Optional[List[str]]

metric_name

The name of the metric associated with the alarm.

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 .

Link

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cw-alarm.html#cfn-cloudwatch-alarms-metricname

Return type

Optional[str]

metrics

An array that enables you to create an alarm based on the result of a metric math expression.

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 .

Link

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cw-alarm.html#cfn-cloudwatch-alarm-metrics

Return type

Union[IResolvable, List[Union[IResolvable, MetricDataQueryProperty]], None]

namespace

The namespace of the metric associated with the alarm.

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.

Link

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cw-alarm.html#cfn-cloudwatch-alarms-namespace

Return type

Optional[str]

ok_actions

The actions to execute when this alarm transitions to the OK state from any other state.

Each action is specified as an Amazon Resource Name (ARN).

Link

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cw-alarm.html#cfn-cloudwatch-alarms-okactions

Return type

Optional[List[str]]

period

The period, in seconds, over which the statistic is applied.

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

Link

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cw-alarm.html#cfn-cloudwatch-alarms-period

Return type

Union[int, float, None]

statistic

The statistic for the metric associated with the alarm, other than percentile. For percentile statistics, use ExtendedStatistic .

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 .

Link

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cw-alarm.html#cfn-cloudwatch-alarms-statistic

Return type

Optional[str]

threshold

The value to compare with the specified statistic.

Link

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cw-alarm.html#cfn-cloudwatch-alarms-threshold

Return type

Union[int, float, None]

threshold_metric_id

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.

Link

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cw-alarm.html#cfn-cloudwatch-alarms-dynamic-threshold

Return type

Optional[str]

treat_missing_data

Sets how this alarm is to handle missing data points.

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.

Link

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cw-alarm.html#cfn-cloudwatch-alarms-treatmissingdata

Return type

Optional[str]

unit

The unit of the metric associated with the alarm.

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.

Link

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cw-alarm.html#cfn-cloudwatch-alarms-unit

Return type

Optional[str]