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.

Constant Summary collapse

RECONNECT_BACKOFF_SLEEP =
5
TIMESTAMP_GELF_FIELD =
"timestamp".freeze
SOURCE_HOST_FIELD =
"source_host".freeze
MESSAGE_FIELD =
"message"
TAGS_FIELD =
"tags"
PARSE_FAILURE_TAG =
"_jsonparsefailure"
PARSE_FAILURE_LOG_MESSAGE =
"JSON parse failure. Falling back to plain-text"

Instance Method Summary collapse

Constructor Details

#initialize(params) ⇒ Gelf

Returns a new instance of Gelf.



36
37
38
39
# File 'lib/logstash/inputs/gelf.rb', line 36

def initialize(params)
  super
  BasicSocket.do_not_reverse_lookup = true
end

Instance Method Details

#registerObject



42
43
44
# File 'lib/logstash/inputs/gelf.rb', line 42

def register
  require 'gelfd'
end

#run(output_queue) ⇒ Object



47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/logstash/inputs/gelf.rb', line 47

def run(output_queue)
  begin
    # udp server
    udp_listener(output_queue)
  rescue => e
    unless stop?
      @logger.warn("gelf listener died", :exception => e, :backtrace => e.backtrace)
      Stud.stoppable_sleep(RECONNECT_BACKOFF_SLEEP) { stop? }
      retry unless stop?
    end
  end # begin
end

#stopObject



61
62
63
64
# File 'lib/logstash/inputs/gelf.rb', line 61

def stop
  @udp.close
rescue IOError # the plugin is currently shutting down, so its safe to ignore theses errors
end