class AwsRegion::AwsCw

Methods for dealing with CloudWatch

Attributes

region[RW]

Public Class Methods

new(region, options={}) click to toggle source

@param region [String] - Value from REGION static hash

# File lib/aws_region.rb, line 151
def initialize(region, options={})
  @region = region
end

Public Instance Methods

put_metric(arg_csv) click to toggle source

Put a cw metric @param arg_csv [String] - CSV row: “namespace,name,value,dims”

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

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

@return [Aws::PageableResponse]

# 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