Class: LogStash::Filters::Checksum
- Inherits:
-
Base
- Object
- Base
- LogStash::Filters::Checksum
- Defined in:
- lib/logstash/filters/checksum.rb
Overview
This filter let’s you create a checksum based on various parts of the logstash event. This can be useful for deduplication of messages or simply to provide a custom unique identifier.
This is VERY experimental and is largely a proof-of-concept
Constant Summary collapse
- ALGORITHMS =
["md5", "sha", "sha1", "sha256", "sha384",]
Instance Method Summary collapse
Instance Method Details
#filter(event) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/logstash/filters/checksum.rb', line 31 def filter(event) to_checksum = "" @logger.debug("Running checksum filter", :event => event) @keys.sort.each do |k| @logger.debug("Adding key to string", :current_key => k) to_checksum << "#{event.get(k)}" end @logger.debug("Final string built", :to_checksum => to_checksum) # in JRuby 1.7.11 outputs as ASCII-8BIT digested_string = OpenSSL::Digest.hexdigest(@algorithm, to_checksum).force_encoding(Encoding::UTF_8) @logger.debug("Digested string", :digested_string => digested_string) event.set('logstash_checksum', digested_string) end |
#register ⇒ Object
26 27 28 |
# File 'lib/logstash/filters/checksum.rb', line 26 def register require 'openssl' end |