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 contains the HTTP client code within it’s own namespace. It is based off of the logstash-mixin-http_client plugin.

Defined Under Namespace

Modules: HttpClient

Constant Summary collapse

VERSION =
"1.0.0".freeze
CONTENT_TYPE =
"application/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



32
33
34
# File 'lib/logstash/outputs/timber.rb', line 32

def url=(value)
  @url = value
end

Instance Method Details

#closeObject



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

def close
  http_client.close
end

#multi_receive(events) ⇒ Object



62
63
64
# File 'lib/logstash/outputs/timber.rb', line 62

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

#registerObject



51
52
53
54
55
56
57
58
59
60
# File 'lib/logstash/outputs/timber.rb', line 51

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