Class: LogStash::Outputs::Gelf

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

Instance Attribute Summary

Attributes inherited from Base

#logger

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from LogStash::Outputs::Base

Instance Method Details

#receive(event) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/logstash/outputs/gelf.rb', line 18

def receive(event)
  # TODO(sissel): Use Gelf::Message instead
  gelf = GELF::Notifier.new(@url.host, (@url.port or 12201))
  m = Hash.new
  m["short_message"] = (event.fields["message"] or event.message)
  m["full_message"] = (event.message)
  m["host"] = event["@source_host"]
  m["file"] = event["@source_path"]
  m["level"] = 1

  event.fields.each do |name, value|
    next if value == nil or value.empty?
    m["#{name}"] = value
  end
  m["timestamp"] = event.timestamp
  gelf.notify(m)
end

#registerObject



13
14
15
# File 'lib/logstash/outputs/gelf.rb', line 13

def register
  # nothing to do
end