Replies: 1 comment 6 replies
-
|
It looks like your log file is in JSON-lines form, which is directly supported by lnav. You shouldn't have to use a regex to parse it out. The log format reference covers the details of how to write a log format file for a JSON-lines log. Unfortunately, the docs don't have an actual example, but there are some tests you can look at. For this log file: Lines 1 to 13 in 8d17561 The log format file looks like this: lnav/test/formats/jsontest/format.json Lines 1 to 36 in 8d17561 The rendered output then looks like this: (Note that the extra spacing is due to the leading Let me know if you need additional help in creating your format file. |
Beta Was this translation helpful? Give feedback.

Uh oh!
There was an error while loading. Please reload this page.
-
I am using the following regex:
to capture messages in the following format:
{"level":"info","message":"Error running main: - connect ECONNREFUS\"ED ::1:27017","@errorObjectName":"MongoServerSelectionError","@filename":"/data-scraper/dist/src/main.js","@logCallStack":" /data-scraper/src/main.ts:20:13","@packageName":"starter-project","errCallStack":"Error: connect ECONNREFUSED ::1:27017\n at /data-scraper/src/main.ts:20:13Caused By: MongoServerSelectionError: connect ECONNREFUSED ::1:27017\n at Timeout._onTimeout (/data-scraper/node_modules/mongodb/src/sdam/topology.ts:591:30)\n at listOnTimeout (node:internal/timers:564:17)\n at processTimers (node:internal/timers:507:7)","@timestamp":"2023-01-16T14:52:31.874Z"}That works fine, except some fields that show up that are not in the regex, like for example the
@errorObjectNamefield above, it gets captured together as<message>rather than being ignored.So I tried the following regex to achieve that desired behaviour which uses OR to capture the different fields that I want to parse out.
The problem is with the above when I run
lnavI get the following error:So lnav won't allow me to load this formatter unless it fully matches everything......
Is there a way to achieve the behavior that I want? Or is it impossible with
lnav?Beta Was this translation helpful? Give feedback.
All reactions