Sha256: fcd6fe951a97379301bcb7f1ab174f9bb08d15b17abef61e314dec96b6d8d25d

Contents?: true

Size: 867 Bytes

Versions: 1

Compression:

Stored size: 867 Bytes

Contents

require 'fluent/mixin/config_placeholders'

module Fluent
  class RecordModifierOutput < Output
    Fluent::Plugin.register_output('record_modifier', self)

    config_param :tag, :string

    include SetTagKeyMixin
    include Fluent::Mixin::ConfigPlaceholders

    BUILTIN_CONFIGURATIONS = %W(type tag include_tag_key tag_key)

    def configure(conf)
      super

      @map = {}
      conf.each_pair { |k, v|
        unless BUILTIN_CONFIGURATIONS.include?(k)
          conf.has_key?(k)
          @map[k] = v
        end
      }
    end

    def emit(tag, es, chain)
      es.each { |time, record|
        filter_record(tag, time, record)
        Engine.emit(@tag, time, modify_record(record))
      }

      chain.next
    end

    private

    def modify_record(record)
      @map.each_pair { |k, v|
        record[k] = v
      }

      record
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fluent-plugin-record-modifier-0.1.1 lib/fluent/plugin/out_record_modifier.rb