class Bosh::Monitor::Plugins::CloudWatch
Public Class Methods
new(options={})
click to toggle source
# File lib/bosh/monitor/plugins/cloud_watch.rb, line 6 def initialize(options={}) @options = options end
Public Instance Methods
aws_cloud_watch()
click to toggle source
# File lib/bosh/monitor/plugins/cloud_watch.rb, line 10 def aws_cloud_watch @aws_cloud_watch ||= AWS::CloudWatch.new(@options) end
process(event)
click to toggle source
# File lib/bosh/monitor/plugins/cloud_watch.rb, line 17 def process(event) if (event.is_a? Bosh::Monitor::Events::Heartbeat) && event.node_id aws_cloud_watch.put_metric_data(heartbeat_to_cloudwatch_metric(event)) end end
run()
click to toggle source
# File lib/bosh/monitor/plugins/cloud_watch.rb, line 14 def run end
Private Instance Methods
build_metric(metric, dimensions)
click to toggle source
# File lib/bosh/monitor/plugins/cloud_watch.rb, line 45 def build_metric(metric, dimensions) timestamp = Time.at(metric.timestamp).utc.iso8601 { metric_name: metric.name.to_s, value: metric.value.to_s, timestamp: timestamp, dimensions: dimensions } end
dimensions(heartbeat)
click to toggle source
# File lib/bosh/monitor/plugins/cloud_watch.rb, line 34 def dimensions(heartbeat) @dimensions ||= [ {name: "job", value: heartbeat.job}, {name: "index", value: heartbeat.index}, {name: "name", value: "#{heartbeat.job}/#{heartbeat.node_id}"}, {name: "deployment", value: heartbeat.deployment}, {name: "agent_id", value: heartbeat.agent_id}, {name: "id", value: heartbeat.node_id} ] end
heartbeat_to_cloudwatch_metric(heartbeat)
click to toggle source
# File lib/bosh/monitor/plugins/cloud_watch.rb, line 25 def heartbeat_to_cloudwatch_metric(heartbeat) { namespace: "BOSH/HealthMonitor", metric_data: heartbeat.metrics.collect do |metric| build_metric(metric, dimensions(heartbeat)) end } end