Allow grep, when given no patterns, to negate all things

This commit is contained in:
Jordan Sissel 2012-10-19 21:44:30 -07:00
parent 9882988740
commit 09fe7a8c9c

View file

@ -56,6 +56,22 @@ class LogStash::Filters::Grep < LogStash::Filters::Base
@logger.debug("Running grep filter", :event => event, :config => config)
matches = 0
# If negate is set but no patterns are given, drop the event.
# This is useful in cases where you want to drop all events with
# a given type or set of tags
#
# filter {
# grep {
# negate => true
# type => blah
# }
# }
if @negate && @patterns.empty?
event.cancel
return
end
@patterns.each do |field, regexes|
# For each match object, we have to match everything in order to
# apply any fields/tags.