Class: Fluent::FilterListOutput
- Inherits:
-
Output
- Object
- Output
- Fluent::FilterListOutput
- Includes:
- Matchers
- Defined in:
- lib/fluent/plugin/out_filter_list.rb
Instance Method Summary collapse
- #configure(conf) ⇒ Object
- #configure_prefixes ⇒ Object
- #emit(tag, es, _chain) ⇒ Object
-
#initialize ⇒ FilterListOutput
constructor
A new instance of FilterListOutput.
- #validate(retag) ⇒ Object
Constructor Details
#initialize ⇒ FilterListOutput
Returns a new instance of FilterListOutput.
23 24 25 |
# File 'lib/fluent/plugin/out_filter_list.rb', line 23 def initialize super end |
Instance Method Details
#configure(conf) ⇒ Object
39 40 41 42 43 44 45 46 |
# File 'lib/fluent/plugin/out_filter_list.rb', line 39 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
33 34 35 36 37 |
# File 'lib/fluent/plugin/out_filter_list.rb', line 33 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 |
#emit(tag, es, _chain) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/fluent/plugin/out_filter_list.rb', line 48 def emit(tag, es, _chain) 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 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 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
27 28 29 30 31 |
# File 'lib/fluent/plugin/out_filter_list.rb', line 27 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 |