Class: Fluent::LogtailOutput

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

Constant Summary collapse

VERSION =
"0.1.0".freeze
CONTENT_TYPE =
"application/msgpack".freeze
HOST =
"https://in.logtail.com".freeze
PATH =
"/".freeze
MAX_ATTEMPTS =
3.freeze
RETRYABLE_CODES =
[429, 500, 502, 503, 504].freeze
USER_AGENT =
"Logtail Logstash/#{VERSION}".freeze

Instance Method Summary collapse

Instance Method Details

#configure(conf) ⇒ Object



18
19
20
21
22
23
24
25
26
# File 'lib/fluent/plugin/out_logtail.rb', line 18

def configure(conf)
  source_token = conf["source_token"]
  @headers = {
    "Authorization" => "Bearer #{source_token}",
    "Content-Type" => CONTENT_TYPE,
    "User-Agent" => USER_AGENT
  }
  super
end

#format(tag, time, record) ⇒ Object



40
41
42
# File 'lib/fluent/plugin/out_logtail.rb', line 40

def format(tag, time, record)
  record.merge("dt" => Time.at(time).utc.iso8601).to_msgpack
end

#shutdownObject



35
36
37
38
# File 'lib/fluent/plugin/out_logtail.rb', line 35

def shutdown
  @http_client.close if @http_client
  super
end

#startObject



28
29
30
31
32
33
# File 'lib/fluent/plugin/out_logtail.rb', line 28

def start
  super
  require 'http'
  HTTP.default_options = {:keep_alive_timeout => 29}
  @http_client = HTTP.persistent(HOST)
end

#write(chunk) ⇒ Object



44
45
46
# File 'lib/fluent/plugin/out_logtail.rb', line 44

def write(chunk)
  deliver(chunk, 1)
end