Hi
I am trying to parse json which contains arrays within arrays and want it give them as seperate records in elasticsearch using logstash
My input is
[{"root":[{"data":[{"id1" : [{"value":"1"}],"id2" : [{"value":"1"}]}]}]}]
My code
input {
stdin{
codec=>"json"
}
}
filter {
json{
source=>"message"
}
split{
field=>"[root]"
}
split{
field=>"[root][data]"
}
split{
field=>"[root][data][id1]"
}
split{
field=>"[root][data][id2]"
}}
output {
stdout{
codec => rubydebug
}
I am currently getting the output as
{
"@timestamp" => 2017-03-15T14:19:11.720Z,
"root" => {
"data" => {
"id2" => {
"value" => "1"
},
"id1" => {
"value" => "1"
}
}
},
"@version" => "1",
"host" => "localhost.localdomain"
}
My desired output should contains two records in elasticsearch as
{
"@timestamp" => 2017-03-15T14:19:11.720Z,
"root" => {
"data" => {
"id1" => {
"value" => "1"
}
}
},
"@version" => "1",
"host" => "localhost.localdomain"
}, {
"@timestamp" => 2017-03-15T14:19:11.720Z,
"root" => {
"data" => {
"id2" => {
"value" => "1"
}
}
},
"@version" => "1",
"host" => "localhost.localdomain"
}
Could any one help me to do this,
Thanks in advance