CloudWatch Reference

boto.ec2.cloudwatch

This module provides an interface to the Elastic Compute Cloud (EC2) CloudWatch service from AWS.

class boto.ec2.cloudwatch.CloudWatchConnection(aws_access_key_id=None, aws_secret_access_key=None, is_secure=True, port=None, proxy=None, proxy_port=None, proxy_user=None, proxy_pass=None, debug=0, https_connection_factory=None, region=None, path='/')

Init method to create a new connection to EC2 Monitoring Service.

B{Note:} The host argument is overridden by the host specified in the boto configuration file.

APIVersion = '2010-08-01'
DefaultRegionEndpoint = 'monitoring.us-east-1.amazonaws.com'
DefaultRegionName = 'us-east-1'
build_dimension_param(dimension, params)
build_list_params(params, items, label)
build_put_params(params, name, value=None, timestamp=None, unit=None, dimensions=None, statistics=None)
create_alarm(alarm)

Creates or updates an alarm and associates it with the specified Amazon CloudWatch metric. Optionally, this operation can associate one or more Amazon Simple Notification Service resources with the alarm.

When this operation creates an alarm, the alarm state is immediately set to INSUFFICIENT_DATA. The alarm is evaluated and its StateValue is set appropriately. Any actions associated with the StateValue is then executed.

When updating an existing alarm, its StateValue is left unchanged.

Parameters:alarm (boto.ec2.cloudwatch.alarm.MetricAlarm) – MetricAlarm object.
delete_alarms(alarms)

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

Parameters:alarms (list) – List of alarm names.
describe_alarm_history(alarm_name=None, start_date=None, end_date=None, max_records=None, history_item_type=None, next_token=None)

Retrieves history for the specified alarm. Filter alarms by date range or item type. If an alarm name is not specified, Amazon CloudWatch returns histories for all of the owner’s alarms.

Amazon CloudWatch retains the history of deleted alarms for a period of six weeks. If an alarm has been deleted, its history can still be queried.

Parameters:
  • alarm_name (string) – The name of the alarm.
  • start_date (datetime) – The starting date to retrieve alarm history.
  • end_date (datetime) – The starting date to retrieve alarm history.
  • history_item_type (string) – The type of alarm histories to retreive (ConfigurationUpdate | StateUpdate | Action)
  • max_records (int) – The maximum number of alarm descriptions to retrieve.
  • next_token (string) – The token returned by a previous call to indicate that there is more data.

:rtype list

describe_alarms(action_prefix=None, alarm_name_prefix=None, alarm_names=None, max_records=None, state_value=None, next_token=None)

Retrieves alarms with the specified names. If no name is specified, all alarms for the user are returned. Alarms can be retrieved by using only a prefix for the alarm name, the alarm state, or a prefix for any action.

Parameters:
  • action_name – The action name prefix.
  • alarm_name_prefix (string) – The alarm name prefix. AlarmNames cannot be specified if this parameter is specified.
  • alarm_names (list) – A list of alarm names to retrieve information for.
  • max_records (int) – The maximum number of alarm descriptions to retrieve.
  • state_value (string) – The state value to be used in matching alarms.
  • next_token (string) – The token returned by a previous call to indicate that there is more data.

:rtype list

describe_alarms_for_metric(metric_name, namespace, period=None, statistic=None, dimensions=None, unit=None)

Retrieves all alarms for a single metric. Specify a statistic, period, or unit to filter the set of alarms further.

Parameters:
  • metric_name (string) – The name of the metric
  • namespace (string) – The namespace of the metric.
  • period (int) – The period in seconds over which the statistic is applied.
  • statistic (string) – The statistic for the metric.
  • dimension_filters – A dictionary containing name/value pairs that will be used to filter the results. The key in the dictionary is the name of a Dimension. The value in the dictionary is either a scalar value of that Dimension name that you want to filter on, a list of values to filter on or None if you want all metrics with that Dimension name.

:rtype list

disable_alarm_actions(alarm_names)

Disables actions for the specified alarms.

Parameters:alarms (list) – List of alarm names.
enable_alarm_actions(alarm_names)

Enables actions for the specified alarms.

Parameters:alarms (list) – List of alarm names.
get_metric_statistics(period, start_time, end_time, metric_name, namespace, statistics, dimensions=None, unit=None)

Get time-series data for one or more statistics of a given metric.

Parameters:
  • period (integer) – The granularity, in seconds, of the returned datapoints. Period must be at least 60 seconds and must be a multiple of 60. The default value is 60.
  • start_time (datetime) – The time stamp to use for determining the first datapoint to return. The value specified is inclusive; results include datapoints with the time stamp specified.
  • end_time (datetime) – The time stamp to use for determining the last datapoint to return. The value specified is exclusive; results will include datapoints up to the time stamp specified.
  • metric_name (string) – The metric name.
  • namespace (string) – The metric’s namespace.
  • statistics (list) – A list of statistics names Valid values: Average | Sum | SampleCount | Maximum | Minimum
  • dimensions (dict) – A dictionary of dimension key/values where the key is the dimension name and the value is either a scalar value or an iterator of values to be associated with that dimension.
Return type:

list

list_metrics(next_token=None, dimensions=None, metric_name=None, namespace=None)

Returns a list of the valid metrics for which there is recorded data available.

Parameters:
  • next_token (str) – A maximum of 500 metrics will be returned at one time. If more results are available, the ResultSet returned will contain a non-Null next_token attribute. Passing that token as a parameter to list_metrics will retrieve the next page of metrics.
  • dimension_filters – A dictionary containing name/value pairs that will be used to filter the results. The key in the dictionary is the name of a Dimension. The value in the dictionary is either a scalar value of that Dimension name that you want to filter on, a list of values to filter on or None if you want all metrics with that Dimension name.
  • metric_name (str) – The name of the Metric to filter against. If None, all Metric names will be returned.
  • namespace (str) – A Metric namespace to filter against (e.g. AWS/EC2). If None, Metrics from all namespaces will be returned.
put_metric_alarm(alarm)

Creates or updates an alarm and associates it with the specified Amazon CloudWatch metric. Optionally, this operation can associate one or more Amazon Simple Notification Service resources with the alarm.

When this operation creates an alarm, the alarm state is immediately set to INSUFFICIENT_DATA. The alarm is evaluated and its StateValue is set appropriately. Any actions associated with the StateValue is then executed.

When updating an existing alarm, its StateValue is left unchanged.

Parameters:alarm (boto.ec2.cloudwatch.alarm.MetricAlarm) – MetricAlarm object.
put_metric_data(namespace, name, value=None, timestamp=None, unit=None, dimensions=None, statistics=None)

Publishes metric data points to Amazon CloudWatch. Amazon Cloudwatch associates the data points with the specified metric. If the specified metric does not exist, Amazon CloudWatch creates the metric. If a list is specified for some, but not all, of the arguments, the remaining arguments are repeated a corresponding number of times.

Parameters:
  • namespace (str) – The namespace of the metric.
  • name (str or list) – The name of the metric.
  • value (float or list) – The value for the metric.
  • timestamp (datetime or list) – The time stamp used for the metric. If not specified, the default value is set to the time the metric data was received.
  • unit (string or list) – The unit of the metric. Valid 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 | None
  • dimensions (dict) – Add extra name value pairs to associate with the metric, i.e.: {‘name1’: value1, ‘name2’: (value2, value3)}
  • statistics (dict or list) –

    Use a statistic set instead of a value, for example:

    {'maximum': 30, 'minimum': 1, 'samplecount': 100, 'sum': 10000}
    
set_alarm_state(alarm_name, state_reason, state_value, state_reason_data=None)

Temporarily sets the state of an alarm. When the updated StateValue differs from the previous value, the action configured for the appropriate state is invoked. This is not a permanent change. The next periodic alarm check (in about a minute) will set the alarm to its actual state.

Parameters:
  • alarm_name (string) – Descriptive name for alarm.
  • state_reason (string) – Human readable reason.
  • state_value (string) – OK | ALARM | INSUFFICIENT_DATA
  • state_reason_data (string) – Reason string (will be jsonified).
update_alarm(alarm)

Creates or updates an alarm and associates it with the specified Amazon CloudWatch metric. Optionally, this operation can associate one or more Amazon Simple Notification Service resources with the alarm.

When this operation creates an alarm, the alarm state is immediately set to INSUFFICIENT_DATA. The alarm is evaluated and its StateValue is set appropriately. Any actions associated with the StateValue is then executed.

When updating an existing alarm, its StateValue is left unchanged.

Parameters:alarm (boto.ec2.cloudwatch.alarm.MetricAlarm) – MetricAlarm object.
boto.ec2.cloudwatch.connect_to_region(region_name, **kw_params)

Given a valid region name, return a boto.ec2.cloudwatch.CloudWatchConnection.

Parameters:region_name (str) – The name of the region to connect to.
Return type:boto.ec2.CloudWatchConnection or None
Returns:A connection to the given region, or None if an invalid region name is given
boto.ec2.cloudwatch.regions()

Get all available regions for the CloudWatch service.

Return type:list
Returns:A list of boto.RegionInfo instances

boto.ec2.cloudwatch.datapoint

class boto.ec2.cloudwatch.datapoint.Datapoint(connection=None)
endElement(name, value, connection)
startElement(name, attrs, connection)

boto.ec2.cloudwatch.metric

class boto.ec2.cloudwatch.metric.Metric(connection=None)
Statistics = ['Minimum', 'Maximum', 'Sum', 'Average', 'SampleCount']
Units = ['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]
create_alarm(name, comparison, threshold, period, evaluation_periods, statistic, enabled=True, description=None, dimensions=None, alarm_actions=None, ok_actions=None, insufficient_data_actions=None, unit=None)
describe_alarms(period=None, statistic=None, dimensions=None, unit=None)
endElement(name, value, connection)
query(start_time, end_time, statistics, unit=None, period=60)
startElement(name, attrs, connection)