Class: LogStash::Filters::Anonymize

Inherits:
Base show all
Defined in:
lib/logstash/filters/anonymize.rb

Overview

Anonymize fields using by replacing values with a consistent hash.

Constant Summary

Constants inherited from Base

Base::RESERVED

Constants included from Config::Mixin

Config::Mixin::CONFIGSORT

Instance Attribute Summary

Attributes included from Config::Mixin

#config, #original_params

Attributes inherited from Plugin

#logger, #params

Instance Method Summary collapse

Methods inherited from Base

#execute, #initialize, #threadsafe?

Methods included from Config::Mixin

#config_init, included

Methods inherited from Plugin

#eql?, #finished, #finished?, #hash, #initialize, #inspect, lookup, #reload, #running?, #shutdown, #teardown, #terminating?, #to_s

Constructor Details

This class inherits a constructor from LogStash::Filters::Base

Instance Method Details

#filter(event) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
# File 'lib/logstash/filters/anonymize.rb', line 38

def filter(event)
  return unless filter?(event)
  @fields.each do |field|
    next unless event.include?(field)
    if event[field].is_a?(Array)
      event[field] = event[field].collect { |v| anonymize(v) }
    else
      event[field] = anonymize(event[field])
    end
  end
end

#registerObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/logstash/filters/anonymize.rb', line 22

def register
  # require any library and set the anonymize function
  case @algorithm
  when "IPV4_NETWORK"
    require 'ipaddr'
    class << self; alias_method :anonymize, :anonymize_ipv4_network; end
  when "MURMUR3"
    require "murmurhash3"
    class << self; alias_method :anonymize, :anonymize_murmur3; end
  else
    require 'openssl'
    class << self; alias_method :anonymize, :anonymize_openssl; end
  end
end