Sha256: 71c0330e594c5256856987113d86d1a47dc11f832adc78f0f2a96e15d058bde4

Contents?: true

Size: 983 Bytes

Versions: 5

Compression:

Stored size: 983 Bytes

Contents

# GELF output
# http://www.graylog2.org/about/gelf
#
# This class doesn't currently use 'eventmachine'-style code, so it may
# block things. Whatever, we can fix that later ;)

require "gelf" # rubygem 'gelf'
require "logstash/namespace"
require "logstash/outputs/base"

class LogStash::Outputs::Gelf < LogStash::Outputs::Base
  public
  def register
    # nothing to do
  end # def register

  public
  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 # def receive
end # class LogStash::Outputs::Gelf

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
logstash-lite-0.2.20110329105411 lib/logstash/outputs/gelf.rb
logstash-lite-0.2.20110206003603 lib/logstash/outputs/gelf.rb
logstash-lite-0.2.20110203130400 lib/logstash/outputs/gelf.rb
logstash-lite-0.2.20110122143801 lib/logstash/outputs/gelf.rb
logstash-lite-0.2.20110112115019 lib/logstash/outputs/gelf.rb