Class: Fluent::TimberOutput
- Inherits:
-
BufferedOutput
- Object
- BufferedOutput
- Fluent::TimberOutput
- Defined in:
- lib/fluent/plugin/out_timber.rb
Constant Summary collapse
- VERSION =
"1.0.0".freeze
- CONTENT_TYPE =
"application/json".freeze
- HOST =
"https://logs.timber.io".freeze
- MAX_ATTEMPTS =
3.freeze
- PATH =
"/frames".freeze
- RETRYABLE_CODES =
[429, 500, 502, 503, 504].freeze
- USER_AGENT =
"Timber Logstash/#{VERSION}".freeze
Instance Method Summary collapse
- #configure(conf) ⇒ Object
- #format(tag, time, record) ⇒ Object
- #shutdown ⇒ Object
- #start ⇒ Object
- #write(chunk) ⇒ Object
Instance Method Details
#configure(conf) ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/fluent/plugin/out_timber.rb', line 22 def configure(conf) encoded_api_key = Base64.urlsafe_encode64(conf["api_key"]).chomp = "Basic #{encoded_api_key}" @headers = { "Authorization" => , "Content-Type" => CONTENT_TYPE, "User-Agent" => USER_AGENT } super end |
#format(tag, time, record) ⇒ Object
45 46 47 48 |
# File 'lib/fluent/plugin/out_timber.rb', line 45 def format(tag, time, record) dt_iso8601 = Time.at(time).utc.iso8601 record.merge("dt" => dt_iso8601).to_msgpack end |
#shutdown ⇒ Object
40 41 42 43 |
# File 'lib/fluent/plugin/out_timber.rb', line 40 def shutdown @http_client.close if @http_client super end |
#start ⇒ Object
33 34 35 36 37 38 |
# File 'lib/fluent/plugin/out_timber.rb', line 33 def start super require 'http' HTTP. = {:keep_alive_timeout => 29} @http_client = HTTP.persistent(HOST) end |
#write(chunk) ⇒ Object
50 51 52 |
# File 'lib/fluent/plugin/out_timber.rb', line 50 def write(chunk) deliver(chunk, 1) end |