Sha256: e4a6c04bc9796138a932f96595cb5e6da42e2475e180855367307ae64bf9236d

Contents?: true

Size: 616 Bytes

Versions: 1

Compression:

Stored size: 616 Bytes

Contents

require 'fluent/plugin/record_serializer'

module Fluent
  class RecordSerializerFilter < Filter
    Fluent::Plugin.register_filter('record_serializer', self)

    config_param :format, :string, :default => 'json'
    config_param :field_name, :string, :default => 'payload'

    include SetTagKeyMixin
    include Fluent::RecordSerializer

    def filter(tag, time, record)
      begin
        serialized_record = serialize_record(@format, record)
      rescue => e
        $log.warn "serialize error: #{e.message}"
        return
      end

      {'tag' => tag, @field_name => serialized_record}
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fluent-plugin-record-serializer-0.1.0 lib/fluent/plugin/filter_record_serializer.rb