Class: Eye::Notify::DataDog

Inherits:
Eye::Notify show all
Defined in:
lib/eye/notify/datadog.rb

Instance Method Summary collapse

Instance Method Details

#executeObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/eye/notify/datadog.rb', line 17

def execute
  options = {
    alert_type: "error",
    aggregation_key: msg_host + msg_full_name,
    source_type: "None",
    tags: ["eye"],
  }

  options[:alert_type] = alert_type if alert_type
  options[:aggregation_key] = aggregation_key if aggregation_key
  options[:source_type] = source_type if source_type
  options[:tags] = tags if tags

  event = Dogapi::Event.new(
    message_body,
    aggregation_key: options[:aggregation_key],
    alert_type: options[:alert_type],
    msg_title: message_subject,
    host: msg_host,
    source_type: options[:source_type],
    tags: options[:tags],
  )

  Dogapi::Client.new(api_key).emit_event(event)
end