Class: Bosh::Monitor::Plugins::DataDog

Inherits:
Base
  • Object
show all
Defined in:
lib/bosh/monitor/plugins/datadog.rb

Constant Summary collapse

NORMAL_PRIORITY =
[:alert, :critical, :error]

Instance Attribute Summary

Attributes inherited from Base

#event_kinds, #logger, #options

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Bosh::Monitor::Plugins::Base

Instance Method Details

#dog_clientObject



21
22
23
24
25
# File 'lib/bosh/monitor/plugins/datadog.rb', line 21

def dog_client
  return @dog_client if @dog_client
  client = Dogapi::Client.new(@api_key, @application_key)
  @dog_client = @pagerduty_service_name ? PagingDatadogClient.new(@pagerduty_service_name, client) : client
end

#process(event) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/bosh/monitor/plugins/datadog.rb', line 27

def process(event)
  case event
    when Bosh::Monitor::Events::Heartbeat
      if event.node_id
        EM.defer { process_heartbeat(event) }
      end
    when Bosh::Monitor::Events::Alert
      EM.defer { process_alert(event) }
    else
      #ignore
  end
end

#runObject



13
14
15
16
17
18
19
# File 'lib/bosh/monitor/plugins/datadog.rb', line 13

def run
  @api_key = options["api_key"]
  @application_key = options["application_key"]
  @pagerduty_service_name = options["pagerduty_service_name"]

  logger.info("DataDog plugin is running...")
end

#validate_optionsObject



9
10
11
# File 'lib/bosh/monitor/plugins/datadog.rb', line 9

def validate_options
  !!(options.kind_of?(Hash) && options["api_key"] && options["application_key"])
end