Module: Fluent::PluginHelper::Extract
- Defined in:
- lib/fluent/plugin_helper/extract.rb
Defined Under Namespace
Modules: ExtractParams
Class Method Summary collapse
Instance Method Summary collapse
- #configure(conf) ⇒ Object
- #extract_tag_from_record(record) ⇒ Object
- #extract_time_from_record(record) ⇒ Object
- #initialize ⇒ Object
Class Method Details
.included(mod) ⇒ Object
63 64 65 |
# File 'lib/fluent/plugin_helper/extract.rb', line 63 def self.included(mod) mod.include ExtractParams end |
Instance Method Details
#configure(conf) ⇒ Object
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 |
# File 'lib/fluent/plugin_helper/extract.rb', line 77 def configure(conf) super if @extract_config @_extract_tag_key = @extract_config.tag_key @_extract_keep_tag_key = @extract_config.keep_tag_key @_extract_time_key = @extract_config.time_key if @_extract_time_key @_extract_keep_time_key = @extract_config.keep_time_key @_extract_time_parser = case @extract_config.time_type when :float then Fluent::NumericTimeParser.new(:float) when :unixtime then Fluent::NumericTimeParser.new(:unixtime) else localtime = @extract_config.localtime && !@extract_config.utc Fluent::TimeParser.new(@extract_config.time_format, localtime, @extract_config.timezone) end else if @extract_config.time_format log.warn "'time_format' specified without 'time_key', will be ignored" end end @_extract_enabled = @_extract_tag_key || @_extract_time_key end end |
#extract_tag_from_record(record) ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/fluent/plugin_helper/extract.rb', line 24 def extract_tag_from_record(record) return nil unless @_extract_enabled if @_extract_tag_key && record.has_key?(@_extract_tag_key) v = @_extract_keep_tag_key ? record[@_extract_tag_key] : record.delete(@_extract_tag_key) return v.to_s end nil end |
#extract_time_from_record(record) ⇒ Object
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/fluent/plugin_helper/extract.rb', line 35 def extract_time_from_record(record) return nil unless @_extract_enabled if @_extract_time_key && record.has_key?(@_extract_time_key) v = @_extract_keep_time_key ? record[@_extract_time_key] : record.delete(@_extract_time_key) return @_extract_time_parser.call(v) end nil end |
#initialize ⇒ Object
67 68 69 70 71 72 73 74 75 |
# File 'lib/fluent/plugin_helper/extract.rb', line 67 def initialize super @_extract_enabled = false @_extract_tag_key = nil @_extract_keep_tag_key = nil @_extract_time_key = nil @_extract_keep_time_key = nil @_extract_time_parser = nil end |