Class: Nephelae::Metrics
- Inherits:
-
Object
- Object
- Nephelae::Metrics
- Defined in:
- lib/nephelae/cloud_watch/metrics.rb
Instance Attribute Summary collapse
-
#instance_id ⇒ Object
Returns the value of attribute instance_id.
-
#mcount ⇒ Object
readonly
Returns the value of attribute mcount.
-
#namespace ⇒ Object
Returns the value of attribute namespace.
-
#params ⇒ Object
Returns the value of attribute params.
Instance Method Summary collapse
- #append_metric(name, value, options = {}) ⇒ Object
-
#initialize(namespace, options = {}) ⇒ Metrics
constructor
A new instance of Metrics.
Constructor Details
#initialize(namespace, options = {}) ⇒ Metrics
Returns a new instance of Metrics.
7 8 9 10 11 12 13 14 |
# File 'lib/nephelae/cloud_watch/metrics.rb', line 7 def initialize(namespace, = {}) #code to get the instance id from ec2 metadata @instance_id = [:instance_id] || AWS.get_instance_id @params = {} @params['Action'] = 'PutMetricData' @params['Namespace'] = namespace @mcount = 0 end |
Instance Attribute Details
#instance_id ⇒ Object
Returns the value of attribute instance_id.
3 4 5 |
# File 'lib/nephelae/cloud_watch/metrics.rb', line 3 def instance_id @instance_id end |
#mcount ⇒ Object (readonly)
Returns the value of attribute mcount.
5 6 7 |
# File 'lib/nephelae/cloud_watch/metrics.rb', line 5 def mcount @mcount end |
#namespace ⇒ Object
Returns the value of attribute namespace.
3 4 5 |
# File 'lib/nephelae/cloud_watch/metrics.rb', line 3 def namespace @namespace end |
#params ⇒ Object
Returns the value of attribute params.
3 4 5 |
# File 'lib/nephelae/cloud_watch/metrics.rb', line 3 def params @params end |
Instance Method Details
#append_metric(name, value, options = {}) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/nephelae/cloud_watch/metrics.rb', line 16 def append_metric(name, value, = {}) dim_count = 1 @mcount = @mcount + 1 params["MetricData.member.#{@mcount}.MetricName"] = name params["MetricData.member.#{@mcount}.Value"] = value params["MetricData.member.#{@mcount}.Unit"] = [:unit] || 'None' params["MetricData.member.#{@mcount}.Timestamp"] = [:timestamp] if [:timestamp] if @instance_id params["MetricData.member.#{@mcount}.Dimensions.member.#{dim_count}.Name"] = 'InstanceId' params["MetricData.member.#{@mcount}.Dimensions.member.#{dim_count}.Value"] = @instance_id end end |