Hi All, i have a problem with the logstash split filter.
Any advice or input is greatly appreciated. I have the input as such:
{"SONG_A":[
{
"MD5":"a",
"filename": "x.txt"
},
{
"MD5":"b",
"filename": "y.txt"
}
]
}
I am trying to split the first key into multiple events. The following code works:
filter{
json{
source=>"message"
}
split
{
field => "SONG_A"
}}
Where i am getting the following results:
Event 1:
{
"SONG_A" => {
"filename" => "x.txt",
"MD5" => "a"
}
}
Event 2:
{
"SONG_A" => {
"filename" => "y.txt",
"MD5" => "b"
}
}
However, the key - in this case SONG_A is subject to change, as such a grok filter was created and the value was stashed in the metadata field. However, i am unable to split the key into separate events. The code is as below:
filter{
json{
source=>"message"
}
grok {
match => {"message" => "(?<[@metadata][SONG]>SONG[_A-Z]*)"}
}
split
{
field => "[@metadata][SONG]"
}
However, i am getting the following output where the event is still a single event and not being split as above:
event 1:
{
"@metadata" => {
"SONG" => "SONG_A",
},
"SONG_A" => [
[0] {
"filename" => "x.txt",
"MD5" => "a"
},
[1] {
"filename" => "y.txt",
"MD5" => "b"
}
]
}
Why am i unable to split the event into two events?