mirror of
https://github.com/elastic/logstash.git
synced 2025-04-24 14:47:19 -04:00
Allow grep, when given no patterns, to negate all things
This commit is contained in:
parent
9882988740
commit
09fe7a8c9c
1 changed files with 16 additions and 0 deletions
|
@ -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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue