Class: AwsRegion::AwsCw

Inherits:
AwsBase show all
Defined in:
lib/aws_region.rb

Overview

Methods for dealing with CloudWatch

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from AwsBase

#log

Constructor Details

#initialize(region, options = {}) ⇒ AwsCw

Returns a new instance of AwsCw.

Parameters:

  • region (String)
    • Value from REGION static hash


151
152
153
# File 'lib/aws_region.rb', line 151

def initialize(region, options={})
  @region = region
end

Instance Attribute Details

#regionObject

Returns the value of attribute region


148
149
150
# File 'lib/aws_region.rb', line 148

def region
  @region
end

Instance Method Details

#put_metric(arg_csv) ⇒ Aws::PageableResponse

Put a cw metric

  • Note that dims is formatted as an arbitrary semicolon separated list of name:value dimensions. For example:

    • “activeservers,count,10,env:prod;purp:test”

Parameters:

  • arg_csv (String)
    • CSV row: “namespace,name,value,dims”

Returns:

  • (Aws::PageableResponse)

160
161
162
163
164
165
166
167
168
169
170
171
# File 'lib/aws_region.rb', line 160

def put_metric(arg_csv)
  (namespace, name, value, dims) = arg_csv.split(",")
  dimensions = []
  dims.split(";").each do |d|
    (n, v) = d.split(":")
    dimensions << {:name => n, :value => v}
  end
  args = {:namespace => namespace}
  metric ={:metric_name => name, :value => value.to_f, :timestamp => Time.now, :dimensions => dimensions}
  args[:metric_data] = [metric]
  @region.cw.put_metric_data(args)
end