I am getting logs having a log line which has key value pair separated by pipe. Example-
"apple=1 | banana= 3 | mango=5"
or
"apple=1 | banana= 3 | mango=5 | tiger=7 | elephant=1"
I have to convert this log into a json format using a Logstash filter as follows-
{
"apple": "1"
"banana": "3"
"banana": "5"
}
for first example
and
{
"apple": "1"
"banana": "3"
"banana": "5"
"tiger": "7"
"elepnat": "1"
}
for second example
Note - The number of key value pairs in the log can vary as shown in the above 2 examples.
Is there any filter which can perform the above operation?