Suppose you had events with the following structure:
{
"books": [
{"author":"Alice", "title":"Fields" },
{"author":"Bob", "title":"Oceans" },
{"author":"Connie", "title":"Rivers" },
{"author":"Connie", "title":"Lakes" },
{"author":"David", "title":"Streams"},
{"author":"Eunice", "title":"Creaks" },
]
}
filter {
ruby {
path => "${PWD}/extract-nested-set.logstash-filter-ruby.rb"
script_params => {
source => "[books]"
search => "author"
target => "authors"
unique => true
coerce => true
}
}
}
Would produce an event with:
{
"books": [
{"author":"Alice", "title":"Fields" },
{"author":"Bob", "title":"Oceans" },
{"author":"Connie", "title":"Rivers" },
{"author":"Connie", "title":"Lakes" },
{"author":"David", "title":"Streams"},
{"author":"Eunice", "title":"Creaks" },
],
"authors": ["Alice","Eunice","Bob","David","Connie"]
}