You are viewing documentation for version 2 of the AWS SDK for Ruby. Version 3 documentation can be found here.
Class: Aws::CloudWatch::Metric
 Inherits:

Resources::Resource
 Object
 Resources::Resource
 Aws::CloudWatch::Metric
 Defined in:
 (unknown)
Instance Attribute Summary collapse

#dimensions ⇒ Array<Types::Dimension>
readonly
The dimensions for the metric.

#metric_name ⇒ String
readonly
The name of the metric.

#name ⇒ String
readonly

#namespace ⇒ String
readonly
Attributes inherited from Resources::Resource
Instance Method Summary collapse

#alarms(options = {}) ⇒ Collection<Alarm>
Returns a Collection of Alarm resources.

#get_statistics(options = {}) ⇒ Types::GetMetricStatisticsOutput
Gets statistics for the specified metric.
The maximum number of data points returned from a single call is 1,440.

#initialize ⇒ Object
constructor

#put_alarm(options = {}) ⇒ Alarm

#put_data ⇒ Struct
Publishes metric data points to Amazon CloudWatch.
Methods inherited from Resources::Resource
add_data_attribute, add_identifier, #data, data_attributes, #data_loaded?, identifiers, #load, #wait_until
Methods included from Resources::OperationMethods
#add_batch_operation, #add_operation, #batch_operation, #batch_operation_names, #batch_operations, #operation, #operation_names, #operations
Constructor Details
#initialize(namespace, name, options = {}) ⇒ Object #initialize(options = {}) ⇒ Object
Instance Attribute Details
#dimensions ⇒ Array<Types::Dimension> (readonly)
The dimensions for the metric.
#metric_name ⇒ String (readonly)
The name of the metric. This is a required field.
#name ⇒ String (readonly)
#namespace ⇒ String (readonly)
Instance Method Details
#alarms(options = {}) ⇒ Collection<Alarm>
Returns a Collection of Alarm resources. No API requests are made until you call an enumerable method on the collection. Client#describe_alarms_for_metric will be called multiple times until every Alarm has been yielded.
#get_statistics(options = {}) ⇒ Types::GetMetricStatisticsOutput
Gets statistics for the specified metric.
The maximum number of data points returned from a single call is 1,440. If you request more than 1,440 data points, CloudWatch returns an error. To reduce the number of data points, you can narrow the specified time range and make multiple requests across adjacent time ranges, or you can increase the specified period. Data points are not returned in chronological order.
CloudWatch aggregates data points based on the length of the period that you specify. For example, if you request statistics with a onehour period, CloudWatch aggregates all data points with time stamps that fall within each onehour period. Therefore, the number of values aggregated by CloudWatch is larger than the number of data points returned.
CloudWatch needs raw data points to calculate percentile statistics. If you publish data using a statistic set instead, you can only retrieve percentile statistics for this data if one of the following conditions is true:

The SampleCount value of the statistic set is 1.

The Min and the Max values of the statistic set are equal.
Percentile statistics are not available for metrics when any of the metric values are negative numbers.
Amazon CloudWatch retains metric data as follows:

Data points with a period of less than 60 seconds are available for 3 hours. These data points are highresolution metrics and are available only for custom metrics that have been defined with a
StorageResolution
of 1. 
Data points with a period of 60 seconds (1minute) are available for 15 days.

Data points with a period of 300 seconds (5minute) are available for 63 days.

Data points with a period of 3600 seconds (1 hour) are available for 455 days (15 months).
Data points that are initially published with a shorter period are aggregated together for longterm storage. For example, if you collect data using a period of 1 minute, the data remains available for 15 days with 1minute resolution. After 15 days, this data is still available, but is aggregated and retrievable only with a resolution of 5 minutes. After 63 days, the data is further aggregated and is available with a resolution of 1 hour.
CloudWatch started retaining 5minute and 1hour metric data as of July 9, 2016.
For information about metrics and dimensions supported by AWS services, see the Amazon CloudWatch Metrics and Dimensions Reference in the Amazon CloudWatch User Guide.
#put_alarm(options = {}) ⇒ Alarm
#put_data ⇒ Struct
Publishes metric data points to Amazon CloudWatch. CloudWatch associates the data points with the specified metric. If the specified metric does not exist, CloudWatch creates the metric. When CloudWatch creates a metric, it can take up to fifteen minutes for the metric to appear in calls to ListMetrics.
You can publish either individual data points in the Value
field, or arrays of values and the number of times each value occurred during the period by using the Values
and Counts
fields in the MetricDatum
structure. Using the Values
and Counts
method enables you to publish up to 150 values per metric with one PutMetricData
request, and supports retrieving percentile statistics on this data.
Each PutMetricData
request is limited to 40 KB in size for HTTP POST requests. You can send a payload compressed by gzip. Each request is also limited to no more than 20 different metrics.
Although the Value
parameter accepts numbers of type Double
, CloudWatch rejects values that are either too small or too large. Values must be in the range of 2^{360} to 2^{360}. In addition, special values (for example, NaN, +Infinity, Infinity) are not supported.
You can use up to 10 dimensions per metric to further clarify what data the metric collects. Each dimension consists of a Name and Value pair. For more information about specifying dimensions, see Publishing Metrics in the Amazon CloudWatch User Guide.
Data points with time stamps from 24 hours ago or longer can take at least 48 hours to become available for GetMetricData or GetMetricStatistics from the time they are submitted.
CloudWatch needs raw data points to calculate percentile statistics. If you publish data using a statistic set instead, you can only retrieve percentile statistics for this data if one of the following conditions is true:

The
SampleCount
value of the statistic set is 1 andMin
,Max
, andSum
are all equal. 
The
Min
andMax
are equal, andSum
is equal toMin
multiplied bySampleCount
.