Class: Fog::Rackspace::Monitoring::DataPoints

Inherits:
Collection
  • Object
show all
Defined in:
lib/fog/rackspace/models/monitoring/data_points.rb

Instance Attribute Summary

Attributes inherited from Collection

#service

Instance Method Summary collapse

Methods inherited from Collection

#clear, #create, #destroy, #initialize, #inspect, #load, model, #model, #reload, #table, #to_json

Methods included from Attributes::ClassMethods

#_load, #aliases, #attribute, #attributes, #identity, #ignore_attributes, #ignored_attributes

Methods included from Core::DeprecatedConnectionAccessors

#connection, #connection=, #prepare_service_value

Methods included from Attributes::InstanceMethods

#_dump, #attributes, #dup, #identity, #identity=, #merge_attributes, #new_record?, #persisted?, #requires, #requires_one

Constructor Details

This class inherits a constructor from Fog::Collection

Instance Method Details

#allObject



13
14
15
# File 'lib/fog/rackspace/models/monitoring/data_points.rb', line 13

def all
  self.fetch(:resolution => :full)
end

#fetch(options = {}) ⇒ Object

Fetch the datapoints for a metric

Parameters

  • options<~Hash> - optional paramaters

    • from<~Integer> - timestamp in milliseconds

    • to<~Integer> - timestamp in milliseconds

    • points<~Integer> - Number of points to fetch

    • resolution<~String> - Should be one of :full, :min5, :min20, :min60, :min240, :min1440

    • select<~Array> - Should be an array of :average, :max, :min, :variance

Returns

  • datapoints<~Fog::Rackspace::Monitoring::Datapoints>:



29
30
31
32
33
34
35
36
37
38
39
# File 'lib/fog/rackspace/models/monitoring/data_points.rb', line 29

def fetch(options={})
  requires :metric
  options[:from] ||= (Time.now.to_i * 1000) - (3600 * 1000)
  options[:to] ||= Time.now.to_i * 1000
  options[:points] ||= 1 unless options[:resolution]
  if options[:resolution]
    options[:resolution] = options[:resolution].upcase
  end
  data = service.list_data_points(metric.check.entity.id, metric.check.id, metric.name, options).body['values']
  load(data)
end

#new(attributes = {}) ⇒ Object



41
42
43
44
# File 'lib/fog/rackspace/models/monitoring/data_points.rb', line 41

def new(attributes = {})
  requires :metric
  super({ :metric => metric }.merge!(attributes))
end