How to parse mix json logs


Test the format before parsing...

    dissect { mapping => { "message" => "%{ts} %{+ts} | %{restOfLine}" } }
    if [restOfLine] =~ /{.*}/ {
        json { source => "restOfLine" }
    } else if [restOfLine] =~ /\[.*\]/ {
        mutate { gsub => [ "restOfLine", "^\[", "", "restOfLine", "\]$", "" ] }
        csv { source => "restOfLine" }
    } else {
        # Handle other format
(Amol) #22

Thank you so much for your kind help its working.but i am getting mutiple fields named column in kibana why this is so,could you please explain me.i am adding screen short of it here

if it is not necessary could we remove this.


I assumed you wanted to parse that as a csv. If you do not supply the column names the csv will generate them.

(Amol) #24

ok got it,Thank you Bader.

(Amol) #25

hi Badger,
Now I wanted to parse this as csv and want to provide column names for each value which are separated by comma here


Thank you please help


OK, so use the columns option on the csv filter.

(Amol) #27

Yes I can but the problem is values are not fixed in size they may do I create cloumn names dynamically as per the number values seperated by comma.

Or do I map only few values with same number of columns like I want to map first two values and last one value which is in date formats,and it should come up with date data type in kibana


If you require a different number of columns for different events then you could use a conditional to decide which csv filter to use. Something like

if [message] =~ /.*,.*,.*,.*,.*/
    csv {} # events with 5 fields
else if [message] =~ /.*,.*,.*,.*/
    csv {} # events with 4 fields
(system) closed #29

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