Skip to content

CloudWatchClient.put_metric_alarm

rboto-cloudwatch==0.4.0 · Service index · Types

Model summary (excerpt): Creates or updates an alarm and associates it with the specified metric, metric math expression, anomaly detection model, Metrics Insights query, or PromQL query. For more information about using a Metrics Insights query for an alarm, see Create alarms on Metrics Insights queries . Alarms based on anomaly detection models cannot have Auto Scaling actions. When this operation creates an alarm,...

Install and imports

python -m pip install "rboto[cloudwatch]==0.4.0"
from rboto import CloudWatchClient
from collections.abc import Sequence
from rboto_cloudwatch.types import (
    ActionConfiguration,
    ComparisonOperator,
    Dimension,
    EvaluationCriteria,
    EvaluationWindow,
    MetricDataQuery,
    StandardUnit,
    Statistic,
    Tag,
    WarmUpConfiguration,
)

Signature

async def put_metric_alarm(
    *,
    alarm_name: str,
    alarm_description: str | None = None,
    actions_enabled: bool | None = None,
    ok_actions: Sequence[str] | None = None,
    alarm_actions: Sequence[str] | None = None,
    insufficient_data_actions: Sequence[str] | None = None,
    metric_name: str | None = None,
    namespace: str | None = None,
    statistic: Statistic | None = None,
    extended_statistic: str | None = None,
    dimensions: Sequence[Dimension] | None = None,
    period: int | None = None,
    unit: StandardUnit | None = None,
    evaluation_periods: int | None = None,
    datapoints_to_alarm: int | None = None,
    threshold: float | None = None,
    comparison_operator: ComparisonOperator | None = None,
    treat_missing_data: str | None = None,
    evaluate_low_sample_count_percentile: str | None = None,
    metrics: Sequence[MetricDataQuery] | None = None,
    tags: Sequence[Tag] | None = None,
    threshold_metric_id: str | None = None,
    evaluation_window: EvaluationWindow | None = None,
    warm_up_configuration: WarmUpConfiguration | None = None,
    evaluation_criteria: EvaluationCriteria | None = None,
    evaluation_interval: int | None = None,
    action_configuration: ActionConfiguration | None = None,
) -> None: ...

Arguments without defaults are required. None omits an optional request argument. Static types do not validate resource existence, permissions, lengths, ranges, or conditional service requirements.

Arguments

Argument Required Model notes (excerpt)
alarm_name Yes The name for the alarm. This name must be unique within the Region. The name must contain only UTF-8 characters, and can't contain ASCII control characters
alarm_description No The description for the alarm.
actions_enabled No Indicates whether actions should be executed during any changes to the alarm state. The default is TRUE .
ok_actions No The actions to execute when this alarm transitions to an OK state from any other state. Each action is specified as an Amazon Resource Name (ARN). Valid values: EC2 actions: arn:aws:automate: region :ec2:stop arn:aws:automate: region :ec2:terminate arn:aws:automate: region :ec2:reboot arn:aws:automate: region :ec2:recover arn:aws:swf: region : account-id...
alarm_actions No The actions to execute when this alarm transitions to the ALARM state from any other state. Each action is specified as an Amazon Resource Name (ARN). Valid values: EC2 actions: arn:aws:automate: region :ec2:stop arn:aws:automate: region :ec2:terminate arn:aws:automate: region :ec2:reboot arn:aws:automate: region :ec2:recover arn:aws:swf: region : account-id...
insufficient_data_actions No 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). Valid values: EC2 actions: arn:aws:automate: region :ec2:stop arn:aws:automate: region :ec2:terminate arn:aws:automate: region :ec2:reboot arn:aws:automate: region :ec2:recover arn:aws:swf: region : account-id...
metric_name No The name for the metric associated with the alarm. For each PutMetricAlarm operation, you must specify either MetricName , a Metrics array, or an EvaluationCriteria . If you are creating an alarm based on a math expression, you cannot specify this parameter, or any of the Namespace , Dimensions , Period , Unit , Statistic , or ExtendedStatistic parameters. Instead, you specify all this...
namespace No The namespace for the metric associated specified in MetricName .
statistic No The statistic for the metric specified in MetricName , other than percentile. For percentile statistics, use ExtendedStatistic . When you call PutMetricAlarm and specify a MetricName , you must specify either Statistic or ExtendedStatistic, but not both.
extended_statistic No The extended statistic for the metric specified in MetricName . When you call PutMetricAlarm and specify a MetricName , you must specify either Statistic or ExtendedStatistic but not both. If you specify ExtendedStatistic , the following are valid values: p90 tm90 tc90 ts90 wm90 IQM PR( n : m ) where n and m are values of the metric TC( X %: X %) where X is between 10 and 90 inclusive. TM( X...
dimensions No The dimensions for the metric specified in MetricName .
period No The length, in seconds, used each time the metric specified in MetricName is evaluated. Valid values are 10, 20, 30, and any multiple of 60. Period is required for alarms based on static thresholds. If you are creating an alarm based on a metric math expression, you specify the period for each metric within the objects in the Metrics array. Be sure to specify 10, 20, or 30 only for metrics...
unit No The unit of measure for the statistic. For example, the units for the Amazon EC2 NetworkIn metric are Bytes because NetworkIn tracks the number of bytes that an instance receives on all network interfaces. You can also specify a unit when you create a custom metric. Units help provide conceptual meaning to your data. Metric data points that specify a unit of measure, such as Percent, are...
evaluation_periods No 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.
datapoints_to_alarm No The number of data points 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 .
threshold No The value against which the specified statistic is compared. This parameter is required for alarms based on static thresholds, but should not be used for alarms based on anomaly detection models.
comparison_operator No The arithmetic operation to use when comparing the specified statistic and threshold. The specified statistic value is used as the first operand. The values LessThanLowerOrGreaterThanUpperThreshold , LessThanLowerThreshold , and GreaterThanUpperThreshold are used only for alarms based on anomaly detection models.
treat_missing_data No Sets how this alarm is to handle missing data points. If TreatMissingData is omitted, the default behavior of missing is used. For more information, see Configuring How CloudWatch Alarms Treats Missing Data . Valid Values: breaching | notBreaching | ignore | missing Alarms that evaluate metrics in the AWS/DynamoDB namespace always ignore missing data even if you choose a different option for...
evaluate_low_sample_count_percentile No Used only for alarms based on percentiles. If you specify ignore , the alarm state does not change during periods with too few data points to be statistically significant. If you specify evaluate or omit this parameter, the alarm is always evaluated and possibly changes state no matter how many data points are available. For more information, see Percentile-Based CloudWatch Alarms and Low Data...
metrics No An array of MetricDataQuery structures that enable you to create an alarm based on the result of a metric math expression. For each PutMetricAlarm operation, you must specify either MetricName , a Metrics array, or an EvaluationCriteria . Each item in the Metrics array either retrieves a metric or performs a math expression. One item in the Metrics array is the expression that the alarm...
tags No A list of key-value pairs to associate with the alarm. You can associate as many as 50 tags with an alarm. To be able to associate tags with the alarm when you create the alarm, you must have the cloudwatch:TagResource permission. Tags can help you organize and categorize your resources. You can also use them to scope user permissions by granting a user permission to access or change only...
threshold_metric_id No If this is an alarm based on an anomaly detection model, make this value match the ID of the ANOMALY_DETECTION_BAND function. For an example of how to use this parameter, see the Anomaly Detection Model Alarm example on this page. If your alarm uses this parameter, it cannot have Auto Scaling actions.
evaluation_window No The evaluation window that the alarm uses to select the range of metric data that it evaluates. Specify either a sliding window or a wall clock window. If you omit this parameter, the alarm uses a sliding window. A sliding window advances each time the alarm is evaluated, forming a rolling time window. A wall clock window aligns the evaluated range to fixed clock boundaries, such as the top of...
warm_up_configuration No The warm-up configuration for the alarm. A warm-up period delays alarm evaluation after you create or update the alarm. The warm-up period reduces alarm noise from missing data while a new resource or service starts publishing metrics. For more information, see Alarm warm-up periods in the Amazon CloudWatch User Guide .
evaluation_criteria No The evaluation criteria for the alarm. For each PutMetricAlarm operation, you must specify either MetricName , a Metrics array, or an EvaluationCriteria . If you use the EvaluationCriteria parameter, you cannot include the Namespace , MetricName , Dimensions , Period , Unit , Statistic , ExtendedStatistic , Metrics , Threshold , ComparisonOperator , ThresholdMetricId , EvaluationPeriods , or...
evaluation_interval No The frequency, in seconds, at which the alarm is evaluated. Valid values are 10, 20, 30, and any multiple of 60. This parameter is required for alarms that use EvaluationCriteria , and cannot be specified for alarms configured with MetricName or Metrics .
action_configuration No Settings that change the content of the notifications and events that the alarm sends when its state changes. These settings apply to the alarm's actions, whichever state triggers them.

Output

None.

| None means a value can be absent. Output mappings include every declared key; optional input keys may be omitted. Unknown output enum/union variants are not automatically valid inputs.

ActionConfiguration, ComparisonOperator, Dimension, EvaluationCriteria, EvaluationWindow, MetricDataQuery, StandardUnit, Statistic, Tag, WarmUpConfiguration

Follow these links for nested inputs and outputs; recursive types link back to the same type page.

Pagination and streaming

No generated paginator for this operation.

No output stream.

Errors

Import from rboto_cloudwatch.exceptions:

LimitExceededFaultError.

Other service failures use the service base error; credential, transport and timeout failures use shared errors.

Service guide · Pinned model