Class: Fluent::Plugin::OutDatadogEvent
- Inherits:
-
Output
- Object
- Output
- Fluent::Plugin::OutDatadogEvent
- Defined in:
- lib/fluent/plugin/out_datadog_event.rb
Instance Method Summary collapse
- #configure(conf) ⇒ Object
-
#initialize ⇒ OutDatadogEvent
constructor
A new instance of OutDatadogEvent.
- #post_event(time, event_key, record) ⇒ Object
- #start ⇒ Object
- #write(chunk) ⇒ Object
Constructor Details
#initialize ⇒ OutDatadogEvent
Returns a new instance of OutDatadogEvent.
36 37 38 39 40 41 |
# File 'lib/fluent/plugin/out_datadog_event.rb', line 36 def initialize super require "dogapi" require "date" end |
Instance Method Details
#configure(conf) ⇒ Object
29 30 31 32 33 34 |
# File 'lib/fluent/plugin/out_datadog_event.rb', line 29 def configure(conf) super compat_parameters_convert(conf, :buffer) raise Fluent::ConfigError, "'tag' in chunk_keys is required." if not @chunk_key_tag end |
#post_event(time, event_key, record) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/fluent/plugin/out_datadog_event.rb', line 55 def post_event(time, event_key, record) host = @host if !host host = record["host"] end res = @dog.emit_event(Dogapi::Event.new( "#{record}", :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 )) end |
#start ⇒ Object
43 44 45 46 47 |
# File 'lib/fluent/plugin/out_datadog_event.rb', line 43 def start super @dog = Dogapi::Client.new(@api_key, @app_key) end |
#write(chunk) ⇒ Object
49 50 51 52 53 |
# File 'lib/fluent/plugin/out_datadog_event.rb', line 49 def write(chunk) chunk.each do |time, record| post_event(time, "record", record) end end |