Class: Fluent::LogDNAOutput

Inherits:
BufferedOutput
  • Object
show all
Defined in:
lib/fluent/plugin/out_logdna.rb

Constant Summary collapse

MAX_RETRIES =
5

Instance Method Summary collapse

Instance Method Details

#configure(conf) ⇒ Object



18
19
20
21
# File 'lib/fluent/plugin/out_logdna.rb', line 18

def configure(conf)
  super
  @host = conf['hostname']
end

#format(tag, time, record) ⇒ Object



38
39
40
# File 'lib/fluent/plugin/out_logdna.rb', line 38

def format(tag, time, record)
  [tag, time, record].to_msgpack
end

#shutdownObject



33
34
35
36
# File 'lib/fluent/plugin/out_logdna.rb', line 33

def shutdown
  super
  @ingester.close if @ingester
end

#startObject



23
24
25
26
27
28
29
30
31
# File 'lib/fluent/plugin/out_logdna.rb', line 23

def start
  super
  require 'json'
  require 'base64'
  require 'http'
  HTTP.default_options = { :keep_alive_timeout => 60 }
  @ingester = HTTP.persistent @ingester_domain
  @requests = Queue.new
end

#write(chunk) ⇒ Object



42
43
44
45
46
47
# File 'lib/fluent/plugin/out_logdna.rb', line 42

def write(chunk)
  body = chunk_to_body(chunk)
  response = send_request(body)
  raise 'Encountered server error' if response.code >= 400
  response.flush
end