Class: Fluent::OutDatadogEvent

Inherits:
Output
  • Object
show all
Defined in:
lib/fluent/plugin/out_datadog_event.rb

Instance Method Summary collapse

Constructor Details

#initializeOutDatadogEvent



18
19
20
21
22
23
# File 'lib/fluent/plugin/out_datadog_event.rb', line 18

def initialize
  super
  #
  require "dogapi"
  require "date"
end

Instance Method Details

#emit(tag, es, chain) ⇒ Object



35
36
37
38
39
40
# File 'lib/fluent/plugin/out_datadog_event.rb', line 35

def emit(tag, es, chain)
  chain.next
  es.each do |time,record|
    post_event(time, "record", record)
  end
end

#post_event(time, event_key, event_msg) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/fluent/plugin/out_datadog_event.rb', line 42

def post_event(time, event_key, event_msg)
  res = @dog.emit_event(Dogapi::Event.new(
    "#{event_msg}", 
    :msg_title => @msg_title, 
    :date_happend => time,
    :priority => @priority,
    # :host => @host,
    :tags => @tags,
    :alert_type => @alert_type,
    :aggregation_key => @aggregation_key,
    :source_type_name => @source_type_name
  ))
  # for debug
  #puts "debug_out: #{res}\n"
end

#shutdownObject



30
31
32
33
# File 'lib/fluent/plugin/out_datadog_event.rb', line 30

def shutdown
  @finished = true
  @thread.join
end

#startObject



25
26
27
28
# File 'lib/fluent/plugin/out_datadog_event.rb', line 25

def start
  @dog = Dogapi::Client.new(@api_key, @app_key)
  @finished = false
end