1

I'm using lnav to filter and query on top of the custom log file we have created. As this is a custom log file, I need to create a custom format file and install it using below command to define the structure of the log entries.

lanv -i custom_format.json

Custom format JSON: https://pastebin.com/z7sCVqxd

Though this is working at the high level, I would also like to apply filters using the parameters that are present in body JSON.

The body parameter I've mentioned in the custom formatter is JSON. Not the entire log entry is JSON but only the body parameter value alone is the JSON., In the body parameter only the log level, message and other useful information are present.

Is it possible to use something like,

"level-field" : body.level,
"level" : {
      "error" : "error",
      "warning" : "info"
},

And also how to define other parameters from the body json to Value for defining "kind" and "identifier" or not

Thanks

Baranidharan S
  • 105
  • 1
  • 9

1 Answers1

1

So far I've analyzed I couldn't find any direct solution. I went through the documentation of lnav (here) and found out that there are few JSON functions available which we can use to extract the data from JSON based columns.

with mylog as (select jobserver, workqueue, processid, jget('{"' || col_0 || '"}','/LEVEL') level, jget('{"' || col_0 || '"}','/PREFIX') pid, jget('{"' || col_0 || '"}','/MESSAGE') message from logline) select * from mylog where processid = 358812 limit 1

This temporarily solved the problem. But I'm still looking for the support from lnav API itself.

Baranidharan S
  • 105
  • 1
  • 9