mirror of
https://github.com/elastic/logstash.git
synced 2025-04-24 22:57:16 -04:00
add hooks for after filter
This commit is contained in:
parent
83afe07707
commit
cc8b9214df
1 changed files with 13 additions and 1 deletions
|
@ -9,6 +9,7 @@ class LogStash::FilterWorker < LogStash::Plugin
|
||||||
include Stud
|
include Stud
|
||||||
attr_accessor :logger
|
attr_accessor :logger
|
||||||
attr_accessor :filters
|
attr_accessor :filters
|
||||||
|
attr_reader :after_filter
|
||||||
|
|
||||||
Exceptions = [Exception]
|
Exceptions = [Exception]
|
||||||
Exceptions << java.lang.Exception if RUBY_ENGINE == "jruby"
|
Exceptions << java.lang.Exception if RUBY_ENGINE == "jruby"
|
||||||
|
@ -20,6 +21,13 @@ class LogStash::FilterWorker < LogStash::Plugin
|
||||||
@shutdown_requested = false
|
@shutdown_requested = false
|
||||||
end # def initialize
|
end # def initialize
|
||||||
|
|
||||||
|
#This block is called after each filter is done on an event.
|
||||||
|
#The filtered event and filter class name is passed to the block.
|
||||||
|
#This could be used to add metrics in the future?
|
||||||
|
def after_filter(&block)
|
||||||
|
@after_filter = block
|
||||||
|
end
|
||||||
|
|
||||||
def run
|
def run
|
||||||
# TODO(sissel): Run a flusher thread for each plugin requesting flushes
|
# TODO(sissel): Run a flusher thread for each plugin requesting flushes
|
||||||
# > It seems reasonable that you could want a multiline filter to flush
|
# > It seems reasonable that you could want a multiline filter to flush
|
||||||
|
@ -47,7 +55,10 @@ class LogStash::FilterWorker < LogStash::Plugin
|
||||||
# Filter any events generated so far in this flush.
|
# Filter any events generated so far in this flush.
|
||||||
events.each do |event|
|
events.each do |event|
|
||||||
# TODO(sissel): watchdog on flush filtration?
|
# TODO(sissel): watchdog on flush filtration?
|
||||||
filter.filter(event) unless event.cancelled?
|
unless event.cancelled?
|
||||||
|
filter.filter(event)
|
||||||
|
@after_filter.call(event,filter) unless @after_filter.nil?
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# TODO(sissel): watchdog on flushes?
|
# TODO(sissel): watchdog on flushes?
|
||||||
|
@ -99,6 +110,7 @@ class LogStash::FilterWorker < LogStash::Plugin
|
||||||
:filter => filter.class)
|
:filter => filter.class)
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
|
@after_filter.call(event,filter) unless @after_filter.nil?
|
||||||
end # @filters.each
|
end # @filters.each
|
||||||
|
|
||||||
@logger.debug? and @logger.debug("Event finished filtering", :event => event,
|
@logger.debug? and @logger.debug("Event finished filtering", :event => event,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue