Class: Fluent::TimberOutput
- Inherits:
-
BufferedOutput
- Object
- BufferedOutput
- Fluent::TimberOutput
- Defined in:
- lib/fluent/plugin/out_timber.rb
Constant Summary collapse
- VERSION =
"1.0.1".freeze
- CONTENT_TYPE =
"application/msgpack".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 32 |
# File 'lib/fluent/plugin/out_timber.rb', line 22 def configure(conf) source_id = conf["source_id"] api_key = conf["api_key"] @path = "/sources/#{source_id}/frames" @headers = { "Authorization" => "Bearer #{api_key}", "Content-Type" => CONTENT_TYPE, "User-Agent" => USER_AGENT } super end |
#format(tag, time, record) ⇒ Object
46 47 48 49 |
# File 'lib/fluent/plugin/out_timber.rb', line 46 def format(tag, time, record) dt_iso8601 = Time.at(time).utc.iso8601 record.merge("dt" => dt_iso8601).to_msgpack end |
#shutdown ⇒ Object
41 42 43 44 |
# File 'lib/fluent/plugin/out_timber.rb', line 41 def shutdown @http_client.close if @http_client super end |
#start ⇒ Object
34 35 36 37 38 39 |
# File 'lib/fluent/plugin/out_timber.rb', line 34 def start super require 'http' HTTP. = {:keep_alive_timeout => 29} @http_client = HTTP.persistent(HOST) end |
#write(chunk) ⇒ Object
51 52 53 |
# File 'lib/fluent/plugin/out_timber.rb', line 51 def write(chunk) deliver(chunk, 1) end |