Skip to content

Instantly share code, notes, and snippets.

@areyoutoo
Last active November 5, 2017 01:56
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save areyoutoo/8046708 to your computer and use it in GitHub Desktop.
Save areyoutoo/8046708 to your computer and use it in GitHub Desktop.
Dropping duplicate events in Logstash
# Dropping duplicate events in Logstash
#
# Explanation:
# - Add a hashed field with the anonymize filter (it's fast)
# - ES docs are unique per index/docid, duplicates will be overwritten
# - Set ES "document_id" field when submitting
#
# Caveats:
# - Adds a nonsense field to your events. Annoying but harmless.
# - Make sure that whatever field(s) you hash are unique!
filter {
mutate {
add_field => ["docId", "%{message}"]
}
anonymize {
fields => ["docId"]
key => "pianoPlayingMonkey"
}
}
output {
elasticsearch {
document_id => "%{docId}"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment