Class: LogStash::Outputs::Gelf
- Defined in:
- lib/logstash/outputs/gelf.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(url, config = {}, &block) ⇒ Gelf
constructor
A new instance of Gelf.
- #receive(event) ⇒ Object
- #register ⇒ Object
Constructor Details
#initialize(url, config = {}, &block) ⇒ Gelf
Returns a new instance of Gelf.
14 15 16 17 18 19 20 21 |
# 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 |
Instance Method Details
#receive(event) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/logstash/outputs/gelf.rb', line 33 def receive(event) m = Hash.new m["short_message"] = (event.fields["message"] or event.) m["full_message"] = (event.) 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. @gelf.notify!(m) end |
#register ⇒ Object
24 25 26 27 28 29 30 |
# 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 |