Class: LogStash::Outputs::Timber

Inherits:
Base
  • Object
show all
Includes:
HttpClient
Defined in:
lib/logstash/outputs/timber/http_client.rb,
lib/logstash/outputs/timber.rb

Overview

This is an output class that intelligently forwards logstash events to the Timber.io service.

For a comprehensive overview around how this works and the various configuration options, please see: timber.io/docs/platforms/logstash

Defined Under Namespace

Modules: HttpClient

Constant Summary collapse

VERSION =
"1.0.2".freeze
CONTENT_TYPE =
"application/json".freeze
JSON_SCHEMA =
"https://raw.githubusercontent.com/timberio/log-event-json-schema/v3.1.1/schema.json".freeze
MAX_ATTEMPTS =
3
METHOD =
:post.freeze
RETRYABLE_MANTICORE_EXCEPTIONS =
[
  ::Manticore::Timeout,
  ::Manticore::SocketException,
  ::Manticore::ClientProtocolException,
  ::Manticore::ResolutionFailure,
  ::Manticore::SocketTimeout
].freeze
RETRYABLE_CODES =
[429, 500, 502, 503, 504].freeze
URL =
"https://logs.timber.io/frames".freeze
USER_AGENT =
"Timber Logstash/#{VERSION}".freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from HttpClient

#build_http_client_config, #http_client, included, #setup_http_client_config

Instance Attribute Details

#url=(value) ⇒ Object (writeonly)

Attribute for testing purposes only



37
38
39
# File 'lib/logstash/outputs/timber.rb', line 37

def url=(value)
  @url = value
end

Instance Method Details

#closeObject



71
72
73
# File 'lib/logstash/outputs/timber.rb', line 71

def close
  http_client.close
end

#multi_receive(events) ⇒ Object



67
68
69
# File 'lib/logstash/outputs/timber.rb', line 67

def multi_receive(events)
  send_events(events, 1)
end

#registerObject



56
57
58
59
60
61
62
63
64
65
# File 'lib/logstash/outputs/timber.rb', line 56

def register
  encoded_api_key = Base64.urlsafe_encode64(@api_key).chomp
  authorization_value = "Basic #{encoded_api_key}"
  @headers = {
    "Authorization" => authorization_value,
    "Content-Type" => CONTENT_TYPE,
    "User-Agent" => USER_AGENT
  }
  @url = URL
end