Class: Fluent::GrayLogOutput
- Inherits:
-
BufferedOutput
- Object
- BufferedOutput
- Fluent::GrayLogOutput
- Defined in:
- lib/fluent/plugin/out_graylog.rb
Instance Attribute Summary collapse
-
#endpoint ⇒ Object
readonly
rubocop:enable Style/NumericLiterals.
Instance Method Summary collapse
- #configure(conf) ⇒ Object
- #format(_tag, _time, record) ⇒ Object
-
#initialize ⇒ GrayLogOutput
constructor
A new instance of GrayLogOutput.
- #shutdown ⇒ Object
- #start ⇒ Object
-
#write(chunk) ⇒ Object
rubocop:disable Metrics/AbcSize, Metrics/MethodLength.
Constructor Details
#initialize ⇒ GrayLogOutput
Returns a new instance of GrayLogOutput.
12 13 14 |
# File 'lib/fluent/plugin/out_graylog.rb', line 12 def initialize super end |
Instance Attribute Details
#endpoint ⇒ Object (readonly)
rubocop:enable Style/NumericLiterals
10 11 12 |
# File 'lib/fluent/plugin/out_graylog.rb', line 10 def endpoint @endpoint end |
Instance Method Details
#configure(conf) ⇒ Object
16 17 18 19 |
# File 'lib/fluent/plugin/out_graylog.rb', line 16 def configure(conf) super raise ConfigError, "'host' parameter required" unless conf.key?('host') end |
#format(_tag, _time, record) ⇒ Object
29 30 31 32 |
# File 'lib/fluent/plugin/out_graylog.rb', line 29 def format(_tag, _time, record) # Record must already be in GELF record.to_msgpack end |
#shutdown ⇒ Object
25 26 27 |
# File 'lib/fluent/plugin/out_graylog.rb', line 25 def shutdown super end |
#start ⇒ Object
21 22 23 |
# File 'lib/fluent/plugin/out_graylog.rb', line 21 def start super end |
#write(chunk) ⇒ Object
rubocop:disable Metrics/AbcSize, Metrics/MethodLength
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/fluent/plugin/out_graylog.rb', line 35 def write(chunk) records = [] chunk.msgpack_each do |record| records.push JSON.dump(record) + "\0" # Message delimited by null char end log.debug 'establishing connection with GrayLog' socket = TCPSocket.new @host, @port begin log.debug "sending #{records.count} records in batch" socket.write records.join ensure log.debug 'closing connection with GrayLog' socket.close end end |