Is there any Logstash filter to convert a log-line to json


(Pranav Dixit) #1

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?


(Christian Dahlqvist) #2

Have a look at the kv filter.


(Pranav Dixit) #3

Thanks Christian. It helped.


(system) #4

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.