Hi Guys,
I have a logstash pipeline where I am receiving a JSON file as HTTP input and forwarding it to output plugin.
I want to introduce below structure to input JSON :
"parentField": {
"field0": "value0",
"arrayName": [
{
"field1": "value1",
"field2": "value2"
}
]
}
To achieve that I am trying to use below filter ::
filter {
mutate {
add_field => { "[parentField][field0]" => "value0" }
add_field => { "[parentField][arrayName][0][field1]" => "value1" }
add_field => { "[parentField][arrayName][0][field2]" => "value2" }
}
}
But in this case [0] gets translated to a literal "0" and is being treated as a key instead of array index.
Meaning [parentField][arrayName][0][field1] gets translated to
parentfield => arrayname => "0" => {"field1" => "value1", "field2" => "value2"}
What I am trying to achieve is
parentfield => arrayname => [[0] "field1"=>"value1", "field2" => "value2"]
How do I add an array of fields using mutate's add_filter?