Class: LogStash::Filters::Anonymize

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

Overview

Anonymize fields using by replacing values with a consistent hash.

Instance Method Summary collapse

Instance Method Details

#filter(event) ⇒ Object



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

def 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



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

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