Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions lib/logstash/filters/fingerprint.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,21 @@ class << self; alias_method :fingerprint, :fingerprint_openssl; end
end
end

def serialize(event)
to_string = ""
if event.respond_to?(:to_hash)
to_string << "{"
event.to_hash.sort.map do |k,v|
to_string << "#{k}:#{serialize(v)},"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this would be a breaking change in two ways:

  • current Hash#to_s outputs key/value pairs joined by =>, not by :
  • ordering

end
to_string << "}"
else
to_string << "#{event}"
end

return to_string
end

def filter(event)
case @method
when :UUID
Expand All @@ -120,12 +135,10 @@ def filter(event)
if @concatenate_sources || @concatenate_all_fields
to_string = ""
if @concatenate_all_fields
event.to_hash.sort.map do |k,v|
to_string << "|#{k}|#{v}"
end
to_string << serialize(event)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would be a breaking change for any pipeline configuration that makes uses of concatenate_all_fields, because the string changes from pipe-delimited kv to json-ish.

else
@source.sort.each do |k|
to_string << "|#{k}|#{event.get(k)}"
to_string << "|#{k}|#{serialize(event.get(k))}"
end
end
to_string << "|"
Expand Down