Metric / Collection / alarms

alarms#

CloudWatch.Metric.alarms#

A collection of Alarm resources.A Alarm Collection will include all resources by default, and extreme caution should be taken when performing actions on all resources.

all()#

Creates an iterable of all Alarm resources in the collection.

See also: AWS API Documentation

Request Syntax

alarm_iterator = metric.alarms.all()
Return type:

list(cloudwatch.Alarm)

Returns:

A list of Alarm resources

delete()#

Deletes the specified alarms. You can delete up to 100 alarms in one operation. However, this total can include no more than one composite alarm. For example, you could delete 99 metric alarms and one composite alarms with one operation, but you can’t delete two composite alarms with one operation.

In the event of an error, no alarms are deleted.

Note

It is possible to create a loop or cycle of composite alarms, where composite alarm A depends on composite alarm B, and composite alarm B also depends on composite alarm A. In this scenario, you can’t delete any composite alarm that is part of the cycle because there is always still a composite alarm that depends on that alarm that you want to delete.

To get out of such a situation, you must break the cycle by changing the rule of one of the composite alarms in the cycle to remove a dependency that creates the cycle. The simplest change to make to break a cycle is to change the AlarmRule of one of the alarms to false.

Additionally, the evaluation of composite alarms stops if CloudWatch detects a cycle in the evaluation path.

See also: AWS API Documentation

Request Syntax

response = metric.alarms.delete()
Returns:

None

disable_actions()#

Disables the actions for the specified alarms. When an alarm’s actions are disabled, the alarm actions do not execute when the alarm state changes.

See also: AWS API Documentation

Request Syntax

response = metric.alarms.disable_actions()
Returns:

None

enable_actions()#

Enables the actions for the specified alarms.

See also: AWS API Documentation

Request Syntax

response = metric.alarms.enable_actions()
Returns:

None

filter(**kwargs)#

Creates an iterable of all Alarm resources in the collection filtered by kwargs passed to method. A Alarm collection will include all resources by default if no filters are provided, and extreme caution should be taken when performing actions on all resources.

See also: AWS API Documentation

Request Syntax

alarm_iterator = metric.alarms.filter(
    Statistic='SampleCount'|'Average'|'Sum'|'Minimum'|'Maximum',
    ExtendedStatistic='string',
    Dimensions=[
        {
            'Name': 'string',
            'Value': 'string'
        },
    ],
    Period=123,
    Unit='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'|'None'
)
Parameters:
  • Statistic (string) – The statistic for the metric, other than percentiles. For percentile statistics, use ExtendedStatistics.

  • ExtendedStatistic (string) – The percentile statistic for the metric. Specify a value between p0.0 and p100.

  • Dimensions (list) –

    The dimensions associated with the metric. If the metric has any associated dimensions, you must specify them in order for the call to succeed.

    • (dict) –

      A dimension is a name/value pair that is part of the identity of a metric. Because dimensions are part of the unique identifier for a metric, whenever you add a unique name/value pair to one of your metrics, you are creating a new variation of that metric. For example, many Amazon EC2 metrics publish InstanceId as a dimension name, and the actual instance ID as the value for that dimension.

      You can assign up to 30 dimensions to a metric.

      • Name (string) – [REQUIRED]

        The name of the dimension. Dimension names must contain only ASCII characters, must include at least one non-whitespace character, and cannot start with a colon ( :).

      • Value (string) – [REQUIRED]

        The value of the dimension. Dimension values must contain only ASCII characters and must include at least one non-whitespace character.

  • Period (integer) – The period, in seconds, over which the statistic is applied.

  • Unit (string) – The unit for the metric.

Return type:

list(cloudwatch.Alarm)

Returns:

A list of Alarm resources

limit(**kwargs)#

Creates an iterable up to a specified amount of Alarm resources in the collection.

See also: AWS API Documentation

Request Syntax

alarm_iterator = metric.alarms.limit(
    count=123
)
Parameters:

count (integer) – The limit to the number of resources in the iterable.

Return type:

list(cloudwatch.Alarm)

Returns:

A list of Alarm resources

page_size(**kwargs)#

Creates an iterable of all Alarm resources in the collection, but limits the number of items returned by each service call by the specified amount.

See also: AWS API Documentation

Request Syntax

alarm_iterator = metric.alarms.page_size(
    count=123
)
Parameters:

count (integer) – The number of items returned by each service call

Return type:

list(cloudwatch.Alarm)

Returns:

A list of Alarm resources