Class: LogStash::Filters::Anonymize

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

Overview

deprecated[3.0.3,We recommend that you use the <<plugins-filters-fingerprint,fingerprint filter plugin>> instead.]

Anonymize fields by replacing values with a consistent hash.

Instance Method Summary collapse

Instance Method Details

#filter(event) ⇒ Object



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

def filter(event)
  
  @fields.each do |field|
    next unless event.include?(field)
    if event.get(field).is_a?(Array)
      event.set(field, event.get(field).collect { |v| anonymize(v) })
    else
      event.set(field, anonymize(event.get(field)))
    end
  end
end

#registerObject



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

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