Class: Fluent::SimpleLogentriesOutput
- Inherits:
-
BufferedOutput
- Object
- BufferedOutput
- Fluent::SimpleLogentriesOutput
show all
- Defined in:
- lib/fluent/plugin/out_simple-logentries.rb
Defined Under Namespace
Classes: ConnectionFailure
Constant Summary
collapse
- SSL_HOST =
"api.logentries.com"
- NO_SSL_HOST =
"data.logentries.com"
Instance Method Summary
collapse
Instance Method Details
#client ⇒ Object
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
# File 'lib/fluent/plugin/out_simple-logentries.rb', line 31
def client
@_socket ||= if @use_ssl
context = OpenSSL::SSL::SSLContext.new
socket = TCPSocket.new SSL_HOST, @port
ssl_client = OpenSSL::SSL::SSLSocket.new socket, context
ssl_client.connect
else
if @protocol == 'tcp'
TCPSocket.new NO_SSL_HOST, @port
else
udp_client = UDPSocket.new
udp_client.connect NO_SSL_HOST, @port
udp_client
end
end
end
|
18
19
20
21
|
# File 'lib/fluent/plugin/out_simple-logentries.rb', line 18
def configure(conf)
super
@last_edit = Time.at(0)
end
|
50
51
52
|
# File 'lib/fluent/plugin/out_simple-logentries.rb', line 50
def format(tag, time, record)
return [tag, record].to_msgpack
end
|
#send_logentries(token, data) ⇒ Object
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
# File 'lib/fluent/plugin/out_simple-logentries.rb', line 64
def send_logentries(token, data)
retries = 0
begin
client.write("#{token} #{data} \n")
rescue Errno::ECONNREFUSED, Errno::ETIMEDOUT => e
if retries < @max_retries
retries += 1
@_socket = nil
log.warn "Could not push logs to Logentries, resetting connection and trying again. #{e.message}"
sleep 5**retries
retry
end
raise ConnectionFailure, "Could not push logs to Logentries after #{retries} retries. #{e.message}"
rescue Errno::EMSGSIZE
log.warn "Could not push logs to Logentries. #{e.message}"
end
end
|
#shutdown ⇒ Object
27
28
29
|
# File 'lib/fluent/plugin/out_simple-logentries.rb', line 27
def shutdown
super
end
|
#start ⇒ Object
23
24
25
|
# File 'lib/fluent/plugin/out_simple-logentries.rb', line 23
def start
super
end
|
#write(chunk) ⇒ Object
54
55
56
57
58
59
60
61
62
|
# File 'lib/fluent/plugin/out_simple-logentries.rb', line 54
def write(chunk)
chunk.msgpack_each do |tag, record|
if record.is_a? Hash
send_logentries(@token,
JSON.generate(
@append_tag ? record.merge({tag: tag}) : record))
end
end
end
|