Sha256: f8a850bf867c787bca0b808408410c8fea2fc5ff5530a57325c44b147bccf356

Contents?: true

Size: 1.18 KB

Versions: 1

Compression:

Stored size: 1.18 KB

Contents

require 'fluent/mixin/rewrite_tag_name'

class Fluent::AnonymizerOutput < Fluent::Output
  Fluent::Plugin.register_output('anonymizer', self)

  # To support log_level option since Fluentd v0.10.43
  unless method_defined?(:log)
    define_method(:log) { $log }
  end

  # Define `router` method of v0.12 to support v0.10 or earlier
  unless method_defined?(:router)
    define_method("router") { Fluent::Engine }
  end

  config_param :tag, :string, :default => nil
  config_param :hash_salt, :string, :default => ''
  config_param :ipv4_mask_subnet, :integer, :default => 24
  config_param :ipv6_mask_subnet, :integer, :default => 104

  include Fluent::HandleTagNameMixin
  include Fluent::Mixin::RewriteTagName
  include Fluent::SetTagKeyMixin
  config_set_default :include_tag_key, false

  def initialize
    require 'fluent/plugin/anonymizer'
    super
  end

  def configure(conf)
    super
    @anonymizer = Fluent::Anonymizer.new(self, conf)
  end

  def emit(tag, es, chain)
    es.each do |time, record|
      record = @anonymizer.anonymize(record)
      emit_tag = tag.dup
      filter_record(emit_tag, time, record)
      router.emit(emit_tag, time, record)
    end
    chain.next
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fluent-plugin-anonymizer-0.4.1 lib/fluent/plugin/out_anonymizer.rb