Class: Fluent::Plugin::ParserFilter

Inherits:
Filter show all
Defined in:
lib/fluent/plugin/filter_parser.rb

Constant Summary collapse

REPLACE_CHAR =
'?'.freeze

Constants included from Configurable

Configurable::CONFIG_TYPE_REGISTRY

Instance Attribute Summary collapse

Attributes inherited from Filter

#has_filter_with_time

Attributes included from Fluent::PluginLoggerMixin

#log

Attributes inherited from Base

#under_plugin_development

Instance Method Summary collapse

Methods inherited from Filter

#filter, #filter_with_time, #initialize, #measure_metrics, #statistics

Methods included from Fluent::PluginHelper::Mixin

included

Methods included from Fluent::PluginLoggerMixin

included, #initialize, #terminate

Methods included from Fluent::PluginId

#initialize, #plugin_id, #plugin_id_configured?, #plugin_id_for_test?, #plugin_root_dir, #stop

Methods inherited from Base

#acquire_worker_lock, #after_shutdown, #after_shutdown?, #after_start, #after_started?, #before_shutdown, #before_shutdown?, #called_in_test?, #close, #closed?, #configured?, #context_router, #context_router=, #fluentd_worker_id, #get_lock_path, #has_router?, #initialize, #inspect, #multi_workers_ready?, #plugin_root_dir, #reloadable_plugin?, #shutdown, #shutdown?, #start, #started?, #stop, #stopped?, #string_safe_encoding, #terminate, #terminated?

Methods included from SystemConfig::Mixin

#system_config, #system_config_override

Methods included from Configurable

#config, #configure_proxy_generate, #configured_section_create, included, #initialize, lookup_type, register_type

Constructor Details

This class inherits a constructor from Fluent::Plugin::Filter

Instance Attribute Details

#parserObject (readonly)

Returns the value of attribute parser.



46
47
48
# File 'lib/fluent/plugin/filter_parser.rb', line 46

def parser
  @parser
end

Instance Method Details

#configure(conf) ⇒ Object



48
49
50
51
52
53
54
55
# File 'lib/fluent/plugin/filter_parser.rb', line 48

def configure(conf)
  compat_parameters_convert(conf, :parser)

  super

  @accessor = record_accessor_create(@key_name)
  @parser = parser_create
end

#filter_stream(tag, es) ⇒ Object



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/fluent/plugin/filter_parser.rb', line 59

def filter_stream(tag, es)
  new_es = Fluent::MultiEventStream.new
  es.each do |time, record|
    begin
      raw_value = @accessor.call(record)
      if raw_value.nil?
        new_es.add(time, handle_parsed(tag, record, time, {})) if @reserve_data
        raise ArgumentError, "#{@key_name} does not exist"
      else
        filter_one_record(tag, time, record, raw_value) do |result_time, result_record|
          new_es.add(result_time, result_record)
        end
      end
    rescue => e
      router.emit_error_event(tag, time, record, e) if @emit_invalid_record_to_error
    end
  end
  new_es
end