Class: Fluent::Plugin::FilterListOutput
- Inherits:
-
Output
- Object
- Output
- Fluent::Plugin::FilterListOutput
- Includes:
- BaseFilter, IP, Matchers
- Defined in:
- lib/fluent/plugin/out_filter_list.rb
Instance Method Summary collapse
- #configure(conf) ⇒ Object
- #configure_prefixes ⇒ Object
- #multi_workers_ready? ⇒ Boolean
- #process(tag, es) ⇒ Object
- #start ⇒ Object
- #validate(retag) ⇒ Object
Methods included from BaseFilter
Instance Method Details
#configure(conf) ⇒ Object
46 47 48 49 50 51 52 |
# File 'lib/fluent/plugin/out_filter_list.rb', line 46 def configure(conf) super [@retag, @retag_for_filtered].each { |c| validate c } patterns = @pattern_file_paths.flat_map { |p| File.readlines(p).map(&:strip).reject(&:empty?) } @matcher = (@filter == 'IP') ? IPMatcher.new(patterns) : ACMatcher.new(patterns) configure_prefixes end |
#configure_prefixes ⇒ Object
40 41 42 43 44 |
# File 'lib/fluent/plugin/out_filter_list.rb', line 40 def configure_prefixes @prefix_for_filtered_tag = "#{@retag_for_filtered.add_prefix}." if @retag_for_filtered&.add_prefix @prefix_for_filtered_tag = @retag_for_filtered&.add_prefix ? "#{@retag_for_filtered.add_prefix}." : '' @prefix = @retag&.add_prefix ? "#{@retag.add_prefix}." : '' end |
#multi_workers_ready? ⇒ Boolean
65 66 67 |
# File 'lib/fluent/plugin/out_filter_list.rb', line 65 def multi_workers_ready? true end |
#process(tag, es) ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/fluent/plugin/out_filter_list.rb', line 69 def process(tag, es) es.each do |time, record| target = record[@key_to_filter] log.debug "target: #{target}" # Do filter if should_filter?(target) if @retag_for_filtered t = @retag_for_filtered.tag || ((tag && !tag.empty?) ? @prefix_for_filtered_tag + tag : @retag_for_filtered.add_prefix) log.debug "re-emit with the tag: '#{t}', originally: '#{tag}'" router.emit(t, time, record) end next end t = @retag.tag || ((tag && !tag.empty?) ? @prefix + tag : @retag.add_prefix) log.debug "re-emit with the tag: '#{t}', originally: '#{tag}'" router.emit(t, time, record) end end |
#start ⇒ Object
54 55 56 57 58 59 60 61 62 63 |
# File 'lib/fluent/plugin/out_filter_list.rb', line 54 def start super log.debug sprintf( "@retag: %s, @retag_for_filtered: %s, @prefix: %s, @prefix_for_filtered_tag: %s", @retag, @retag_for_filtered, @prefix, @prefix_for_filtered_tag || '' ) end |
#validate(retag) ⇒ Object
34 35 36 37 38 |
# File 'lib/fluent/plugin/out_filter_list.rb', line 34 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 |