Class: AWS::CloudWatch::MetricStatistics

Inherits:
Object
  • Object
show all
Includes:
AWS::Core::Collection::Simple
Defined in:
lib/aws/cloud_watch/metric_statistics.rb

Overview

Statistics for a metric.

This class is an enumerable collection of data points.

Enumerating Statistics

metric = CloudWatch::Metric.new('my/namepace', 'metric-name')

stats = metric.statistics(
  :start_time => Time.now - 3600,
  :end_time => Time.now,
  :statistics => ['Average'])

stats.label #=> 'some-label'
stats.each do |datapoint|
  # datapoint is a hash
end

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from AWS::Core::Collection

#each, #each_batch, #enum, #first, #in_groups_of, #page

Constructor Details

#initialize(metric, label, datapoints) ⇒ MetricStatistics

Returns a new instance of MetricStatistics.

Parameters:

  • metric (Metric)
  • label (String)
  • datapoints (Array<Hash>)


44
45
46
47
48
# File 'lib/aws/cloud_watch/metric_statistics.rb', line 44

def initialize metric, label, datapoints
  @metric = metric
  @label = label
  @datapoints = datapoints
end

Instance Attribute Details

#datapointsArray<Hash> (readonly)

Returns:

  • (Array<Hash>)


57
58
59
# File 'lib/aws/cloud_watch/metric_statistics.rb', line 57

def datapoints
  @datapoints
end

#labelString (readonly)

Returns:

  • (String)


54
55
56
# File 'lib/aws/cloud_watch/metric_statistics.rb', line 54

def label
  @label
end

#metricMetric (readonly)

Returns:



51
52
53
# File 'lib/aws/cloud_watch/metric_statistics.rb', line 51

def metric
  @metric
end