add grok named_captures_only config option

This commit is contained in:
Pete Fritchman 2011-05-27 15:34:30 -07:00
parent c48efe849c
commit 4ce85e1fc8

View file

@ -51,6 +51,9 @@ class LogStash::Filters::Grok < LogStash::Filters::Base
# requested in: googlecode/issue/26
config :drop_if_match, :validate => :boolean, :default => false
# If true, only store named captures from grok.
config :named_captures_only, :validate => :boolean, :default => false
# Detect if we are running from a jarfile, pick the right path.
@@patterns_path ||= Set.new
if __FILE__ =~ /file:\/.*\.jar!.*/
@ -158,6 +161,11 @@ class LogStash::Filters::Grok < LogStash::Filters::Base
next
end
if @named_captures_only && key.upcase == key
@logger.debug("Skipping capture '#{key}' since it is not a named capture and named_captures_only is true.")
next
end
if event.fields[key].is_a?(String)
event.fields[key] = [event.fields[key]]
elsif event.fields[key] == nil