Class: LogStash::Inputs::Gelf

Inherits:
Base
  • Object
show all
Defined in:
lib/logstash/inputs/gelf.rb

Overview

This input will read GELF messages as events over the network, making it a good choice if you already use Graylog2 today.

The main use case for this input is to leverage existing GELF logging libraries such as the GELF log4j appender.

Instance Method Summary collapse

Constructor Details

#initialize(params) ⇒ Gelf

Returns a new instance of Gelf.



46
47
48
49
50
51
# File 'lib/logstash/inputs/gelf.rb', line 46

def initialize(params)
  super
  BasicSocket.do_not_reverse_lookup = true
  @shutdown_requested = false
  @udp = nil
end

Instance Method Details

#registerObject



54
55
56
# File 'lib/logstash/inputs/gelf.rb', line 54

def register
  require 'gelfd'
end

#run(output_queue) ⇒ Object



59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/logstash/inputs/gelf.rb', line 59

def run(output_queue)
  begin
    # udp server
    udp_listener(output_queue)
  rescue LogStash::ShutdownSignal
    @shutdown_requested = true
  rescue => e
    unless @shutdown_requested
      @logger.warn("gelf listener died", :exception => e, :backtrace => e.backtrace)
      sleep(5)
      retry
    end
  end # begin
end

#teardownObject



75
76
77
78
79
80
81
82
83
# File 'lib/logstash/inputs/gelf.rb', line 75

def teardown
  @shutdown_requested = true
  if @udp
    @udp.close_read rescue nil
    @udp.close_write rescue nil
    @udp = nil
  end
  finished
end