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
# File 'lib/logstash/outputs/gelf.rb', line 18

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

  event.fields.each do |name, value|
    next if value == nil or value.empty?
    gelf.add_additional name, value
  end
  gelf.add_additional "event_timestamp", event.timestamp
  gelf.send
end

#registerObject



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

def register
  # nothing to do
end