Class: LogStash::Filters::Gelfify
- Defined in:
- lib/logstash/filters/gelfify.rb
Overview
The GELFify filter parses RFC3164 severity levels to corresponding GELF levels.
Constant Summary collapse
- SYSLOG_LEVEL_MAP =
{ 0 => 3, # Emergency => FATAL 1 => 5, # Alert => WARN 2 => 3, # Critical => FATAL 3 => 4, # Error => ERROR 4 => 5, # Warning => WARN 5 => 6, # Notice => INFO 6 => 6, # Informat. => INFO 7 => 7 # Debug => DEBUG }
Constants inherited from Base
Constants included from Config::Mixin
Instance Attribute Summary
Attributes included from Config::Mixin
Attributes inherited from Plugin
Instance Method Summary collapse
Methods inherited from Base
#execute, #initialize, #threadsafe?
Methods included from Config::Mixin
Methods inherited from Plugin
#eql?, #finished, #finished?, #hash, #initialize, #inspect, lookup, #reload, #running?, #shutdown, #teardown, #terminating?, #to_s
Constructor Details
This class inherits a constructor from LogStash::Filters::Base
Instance Method Details
#filter(event) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/logstash/filters/gelfify.rb', line 28 def filter(event) return unless event["type"] == @type @logger.debug("GELFIFY FILTER: received event of type #{event["type"]}") if event.include?("severity") sev = event["severity"].to_i rescue nil if sev.to_s != event["severity"].to_s # severity isn't convertable to an integer. # "foo".to_i => 0, which would default to EMERG. @logger.debug("GELFIFY FILTER: existing severity field is not an int") elsif SYSLOG_LEVEL_MAP[sev] @logger.debug("GELFIFY FILTER: Severity level successfully mapped") event["GELF_severity"] = SYSLOG_LEVEL_MAP[sev] else @logger.debug("GELFIFY FILTER: unknown severity #{sev}") end else @logger.debug("GELFIFY FILTER: No 'severity' field found") end if !event.cancelled? filter_matched(event) end end |
#register ⇒ Object
23 24 25 |
# File 'lib/logstash/filters/gelfify.rb', line 23 def register # nothing end |