AlarmProps

class aws_cdk.aws_cloudwatch.AlarmProps(*, evaluation_periods, threshold, actions_enabled=None, alarm_description=None, alarm_name=None, comparison_operator=None, datapoints_to_alarm=None, evaluate_low_sample_count_percentile=None, treat_missing_data=None, metric)

Bases: CreateAlarmOptions

Properties for Alarms.

Parameters:
  • evaluation_periods (Union[int, float]) – The number of periods over which data is compared to the specified threshold.

  • threshold (Union[int, float]) – The value against which the specified statistic is compared.

  • actions_enabled (Optional[bool]) – Whether the actions for this alarm are enabled. Default: true

  • alarm_description (Optional[str]) – Description for the alarm. Default: No description

  • alarm_name (Optional[str]) – Name of the alarm. Default: Automatically generated name

  • comparison_operator (Optional[ComparisonOperator]) – Comparison to use to check if metric is breaching. Default: GreaterThanOrEqualToThreshold

  • 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. For more information, see Evaluating an Alarm in the Amazon CloudWatch User Guide. Default: evaluationPeriods

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

  • treat_missing_data (Optional[TreatMissingData]) – Sets how this alarm is to handle missing data points. Default: TreatMissingData.Missing

  • metric (IMetric) – 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.

ExampleMetadata:

infused

Example:

import aws_cdk.aws_cloudwatch as cloudwatch

# alias: lambda.Alias

# or add alarms to an existing group
# blue_green_alias: lambda.Alias

alarm = cloudwatch.Alarm(self, "Errors",
    comparison_operator=cloudwatch.ComparisonOperator.GREATER_THAN_THRESHOLD,
    threshold=1,
    evaluation_periods=1,
    metric=alias.metric_errors()
)
deployment_group = codedeploy.LambdaDeploymentGroup(self, "BlueGreenDeployment",
    alias=alias,
    deployment_config=codedeploy.LambdaDeploymentConfig.LINEAR_10PERCENT_EVERY_1MINUTE,
    alarms=[alarm
    ]
)
deployment_group.add_alarm(cloudwatch.Alarm(self, "BlueGreenErrors",
    comparison_operator=cloudwatch.ComparisonOperator.GREATER_THAN_THRESHOLD,
    threshold=1,
    evaluation_periods=1,
    metric=blue_green_alias.metric_errors()
))

Attributes

actions_enabled

Whether the actions for this alarm are enabled.

Default:

true

alarm_description

Description for the alarm.

Default:

No description

alarm_name

Name of the alarm.

Default:

Automatically generated name

comparison_operator

Comparison to use to check if metric is breaching.

Default:

GreaterThanOrEqualToThreshold

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. For more information, see Evaluating an Alarm in the Amazon CloudWatch User Guide.

Default:

evaluationPeriods

See:

https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/AlarmThatSendsEmail.html#alarm-evaluation

evaluate_low_sample_count_percentile

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.

evaluation_periods

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

metric

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.

threshold

The value against which the specified statistic is compared.

treat_missing_data

Sets how this alarm is to handle missing data points.

Default:

TreatMissingData.Missing