Class: Fluent::Plugin::FilterListOutput
- Inherits:
-
Output
- Object
- Output
- Fluent::Plugin::FilterListOutput
- Includes:
- Matchers
- Defined in:
- lib/fluent/plugin/out_filter_list.rb
Instance Method Summary collapse
- #configure(conf) ⇒ Object
- #configure_prefixes ⇒ Object
-
#initialize ⇒ FilterListOutput
constructor
A new instance of FilterListOutput.
- #multi_workers_ready? ⇒ Boolean
- #process(tag, es) ⇒ Object
- #validate(retag) ⇒ Object
Constructor Details
#initialize ⇒ FilterListOutput
Returns a new instance of FilterListOutput.
27 28 29 |
# File 'lib/fluent/plugin/out_filter_list.rb', line 27 def initialize super end |
Instance Method Details
#configure(conf) ⇒ Object
43 44 45 46 47 48 49 50 |
# File 'lib/fluent/plugin/out_filter_list.rb', line 43 def configure(conf) super [@retag, @retag_for_filtered].each { |c| validate c } patterns = @patterns_file_path.empty? ? [] : File.readlines(@patterns_file_path).map(&:chomp).reject(&:empty?) @matcher = ACMatcher.new(patterns) configure_prefixes log.debug "prefix: #{@prefix}, prefix_for_filtered_tag: #{@prefix_for_filtered_tag || ''}" end |
#configure_prefixes ⇒ Object
37 38 39 40 41 |
# File 'lib/fluent/plugin/out_filter_list.rb', line 37 def configure_prefixes @prefix_for_filtered_tag = @retag_for_filtered.add_prefix + '.' if @retag_for_filtered && @retag_for_filtered.add_prefix @prefix_for_filtered_tag = @retag_for_filtered && @retag_for_filtered.add_prefix ? @retag_for_filtered.add_prefix + '.' : '' @prefix = @retag && @retag.add_prefix ? @retag.add_prefix + '.' : '' end |
#multi_workers_ready? ⇒ Boolean
52 53 54 |
# File 'lib/fluent/plugin/out_filter_list.rb', line 52 def multi_workers_ready? true end |
#process(tag, es) ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/fluent/plugin/out_filter_list.rb', line 56 def process(tag, es) es.each do |time, record| target = record[@key_to_filter] log.debug "target: #{target}" # Do filter if target && @matcher.matches?(target) if @retag_for_filtered log.debug "@retag_for_filtered: #{@retag_for_filtered}, tag: #{tag}, @prefix_for_filtered_tag: #{@prefix_for_filtered_tag}" tag = @retag_for_filtered.tag || ((tag && !tag.empty?) ? @prefix_for_filtered_tag + tag : @retag_for_filtered.add_prefix) log.debug "re-emit with tag: #{tag}" router.emit(tag, time, record) end next end log.debug "@retag: #{@retag}, tag: #{tag}, @prefix: #{@prefix}" tag = @retag.tag || ((tag && !tag.empty?) ? @prefix + tag : @retag.add_prefix) log.debug "re-emit with tag: #{tag}" router.emit(tag, time, record) end end |
#validate(retag) ⇒ Object
31 32 33 34 35 |
# File 'lib/fluent/plugin/out_filter_list.rb', line 31 def validate(retag) return unless retag raise Fluent::ConfigError, "missing tag and add_prefix" unless retag.tag || retag.add_prefix raise Fluent::ConfigError, "tag and add_prefix are mutually exclusive" if retag.tag && retag.add_prefix end |