class LogStash::Outputs::Gelf
Public Class Methods
new(url, config={}, &block)
click to toggle source
Calls superclass method
LogStash::Outputs::Base::new
# File lib/logstash/outputs/gelf.rb, line 14 def initialize(url, config={}, &block) super @chunksize = @urlopts["chunksize"].to_i || 1420 @level = @urlopts["level"] || 1 @facility = @urlopts["facility"] || 'logstash-gelf' end
Public Instance Methods
receive(event)
click to toggle source
# File lib/logstash/outputs/gelf.rb, line 33 def receive(event) 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
register()
click to toggle source
# File lib/logstash/outputs/gelf.rb, line 24 def register option_hash = Hash.new option_hash["level"] = @level option_hash["facility"] = @facility @gelf = GELF::Notifier.new(@url.host, (@url.port or 12201), @chunksize, option_hash) end