forked from elastic/logstash
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added GELF output to support multiple (frist-value-match) level and facility sources Added syslog support to named labels (cherry picked from commit 8af7a1d)
- Loading branch information
Showing
1 changed file
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
require "logstash/filters/base" | ||
require "logstash/namespace" | ||
|
||
# The GELFify filter parses RFC3164 severity levels to | ||
# corresponding GELF levels. | ||
class LogStash::Filters::Gelfify < LogStash::Filters::Base | ||
|
||
config_name "gelfify" | ||
|
||
public | ||
def register | ||
|
||
@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 | ||
} | ||
|
||
@logger.debug "Adding GELFify filter to type #{@type}" | ||
|
||
end # def register | ||
|
||
public | ||
def filter(event) | ||
|
||
return unless event.type == @type | ||
@logger.debug "GELFIFY FILTER: received event of type #{event.type}" | ||
|
||
if event.fields.include?("severity") | ||
|
||
if @syslog_level_map[event.fields["severity"].to_i] | ||
@logger.debug "GELFIFY FILTER: Severity level successfully mapped" | ||
event.fields["GELF_severity"] = @syslog_level_map[event.fields["severity"].to_i] | ||
end | ||
|
||
else | ||
@logger.warn "GELFIFY FILTER: No 'severity' field found" | ||
end | ||
|
||
if !event.cancelled? | ||
filter_matched(event) | ||
end | ||
end # def filter | ||
|
||
end # class LogStash::Filters::Gelfify |