Skip to content

Commit

Permalink
Add tag "_anonymizefailure" when anonymize fails
Browse files Browse the repository at this point in the history
This eases tracking of events where anonymizing failed.
  • Loading branch information
plusserver-admin committed Sep 6, 2016
1 parent d74724c commit 490caf8
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/logstash/filters/anonymize.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
require "logstash/filters/base"
require "logstash/namespace"

ANONYMIZEFAILURE_TAG = "_anonymizefailure"

# Anonymize fields using by replacing values with a consistent hash.
class LogStash::Filters::Anonymize < LogStash::Filters::Base
config_name "anonymize"
Expand Down Expand Up @@ -53,6 +55,7 @@ def anonymize_ipv4_network(event, field, ip_string)
IPAddr.new(ip_string).mask(@key.to_i).to_s.force_encoding(Encoding::UTF_8)
rescue ArgumentError => e
@logger.error("Anonymize: Invalid IP address received", :field => field, :value => ip_string, :exception => e, :backtrace => e.backtrace)
event.tag(ANONYMIZEFAILURE_TAG)
return ip_string
end
end
Expand Down

0 comments on commit 490caf8

Please sign in to comment.