Class: Fluent::BurrowFilter
- Inherits:
-
Filter
- Object
- Filter
- Fluent::BurrowFilter
- Defined in:
- lib/fluent/plugin/filter_burrow.rb
Instance Method Summary collapse
Instance Method Details
#configure(conf) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/fluent/plugin/filter_burrow.rb', line 30 def configure(conf) super # Validate action actions = ['replace','overlay','inplace','prefix'] if not actions.include? @action raise Fluent::ConfigError, "Invalid 'action', must be one of #{actions.join(',')}" end # Validate action-based restrictions if @action == 'inplace' and @keep_key raise Fluent::ConfigError, "Specifying 'keep_key' with action 'inplace' is not supported" end if @action == 'prefix' and not @data_prefix raise Fluent::ConfigError, "You must specify 'data_prefix' with action 'prefix'" end # Prepare fluent's built-in parser @parser = Fluent::Plugin.new_parser(@format) @parser.configure(conf) if @parser.respond_to?(:configure) end |
#filter(tag, time, record) ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/fluent/plugin/filter_burrow.rb', line 63 def filter(tag, time, record) raw_value = record[@key_name] if raw_value then new_time, new_values = nil, nil @parser.parse(raw_value) do |parsed_time, parsed_values| new_time = parsed_time new_values = parsed_values end if new_values then original_time = record[@record_time_key] new_time ||= original_time # Overlay new record on top of original record? new_record = case @action when 'inplace' record.merge({@key_name => new_values}) when 'overlay' record.merge(new_values) when 'replace' new_values when 'prefix' record.merge({@data_prefix => new_values}) end # Keep the key? if ['overlay','replace','prefix'].include? @action if not @keep_key and new_record.has_key?(@key_name) new_record.delete(@key_name) end end # Preserve 'time' key? if @keep_time new_record[@record_time_key] = original_time end new_record end end end |
#shutdown ⇒ Object
58 59 60 |
# File 'lib/fluent/plugin/filter_burrow.rb', line 58 def shutdown super end |
#start ⇒ Object
53 54 55 |
# File 'lib/fluent/plugin/filter_burrow.rb', line 53 def start super end |