Sha256: b7e453e71dd0039de4b6f960407218218a9c22f550a1026dc5454bcc7533bb1a

Contents?: true

Size: 975 Bytes

Versions: 11

Compression:

Stored size: 975 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"
require "logstash/outputs/base"

class LogStash::Outputs::Gelf < LogStash::Outputs::Base
  def initialize(url, config={}, &block)
    super
  end

  def register
    # nothing to do
  end # def register

  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 event
end # class LogStash::Outputs::Gelf

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
logstash-lite-0.2.20101222161646 lib/logstash/outputs/gelf.rb
logstash-lite-0.2.20101208111718 lib/logstash/outputs/gelf.rb
logstash-lite-0.2.20101207114354 lib/logstash/outputs/gelf.rb
logstash-lite-0.2.20101201111523 lib/logstash/outputs/gelf.rb
logstash-lite-0.2.20101129210156 lib/logstash/outputs/gelf.rb
logstash-lite-0.2.20101129205551 lib/logstash/outputs/gelf.rb
logstash-lite-0.2.20101129155412 lib/logstash/outputs/gelf.rb
logstash-lite-0.2.20101124030048 lib/logstash/outputs/gelf.rb
logstash-lite-0.2.20101124004656 lib/logstash/outputs/gelf.rb
logstash-lite-0.2.20101123134625 lib/logstash/outputs/gelf.rb
logstash-lite-0.2.20101123133737 lib/logstash/outputs/gelf.rb