New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(json): multiple line-format in json logs #1065
Comments
Can you provide some sample inputs and expected outputs. Does the existing |
I have a similar use case. The error messages in the log provide a few fields and the regular messages are more detailed. I would want different line-formats or a way to make portions of the format conditional to not waste so much screen space.
This is the line-format I use with it currently.
|
Kibana 7.x used this format: {"type":"log","@timestamp":"2022-11-15T01:55:25+00:00","tags":["info","status"],"pid":8,"message":"Kibana is now degraded (was available)"}
{"type":"response","@timestamp":"2022-11-15T01:55:28+00:00","tags":["access:console"],"pid":8,"method":"post","statusCode":200,"req":{"url":"/api/console/proxy?path=_aliases%3Fpretty%3Dfalse&method=GET","method":"post","headers":{"host":"localhost:5642","user-agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:106.0) Gecko/20100101 Firefox/106.0","accept":"text/plain, */*; q=0.01","accept-language":"en-US,en;q=0.5","accept-encoding":"gzip, deflate, br","referer":"http://localhost:5642/app/dev_tools","kbn-xsrf":"kibana","origin":"http://localhost:5642","connection":"keep-alive","sec-fetch-dest":"empty","sec-fetch-mode":"cors","sec-fetch-site":"same-origin","content-length":"0"},"remoteAddress":"172.18.0.1","userAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:106.0) Gecko/20100101 Firefox/106.0","referer":"http://localhost:5642/app/dev_tools"},"res":{"statusCode":200,"responseTime":35},"message":"POST /api/console/proxy?path=_aliases%3Fpretty%3Dfalse&method=GET 200 35ms"}
{"type":"response","@timestamp":"2022-11-15T01:55:28+00:00","tags":["access:console"],"pid":8,"method":"post","statusCode":200,"req":{"url":"/api/console/proxy?path=_template%3Fpretty%3Dfalse&method=GET","method":"post","headers":{"host":"localhost:5642","user-agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:106.0) Gecko/20100101 Firefox/106.0","accept":"text/plain, */*; q=0.01","accept-language":"en-US,en;q=0.5","accept-encoding":"gzip, deflate, br","referer":"http://localhost:5642/app/dev_tools","kbn-xsrf":"kibana","origin":"http://localhost:5642","connection":"keep-alive","sec-fetch-dest":"empty","sec-fetch-mode":"cors","sec-fetch-site":"same-origin","content-length":"0"},"remoteAddress":"172.18.0.1","userAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:106.0) Gecko/20100101 Firefox/106.0","referer":"http://localhost:5642/app/dev_tools"},"res":{"statusCode":200,"responseTime":61},"message":"POST /api/console/proxy?path=_template%3Fpretty%3Dfalse&method=GET 200 61ms"}
{"type":"response","@timestamp":"2022-11-15T01:55:28+00:00","tags":["access:console"],"pid":8,"method":"post","statusCode":200,"req":{"url":"/api/console/proxy?path=_mapping%3Fpretty%3Dfalse&method=GET","method":"post","headers":{"host":"localhost:5642","user-agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:106.0) Gecko/20100101 Firefox/106.0","accept":"text/plain, */*; q=0.01","accept-language":"en-US,en;q=0.5","accept-encoding":"gzip, deflate, br","referer":"http://localhost:5642/app/dev_tools","kbn-xsrf":"kibana","origin":"http://localhost:5642","connection":"keep-alive","sec-fetch-dest":"empty","sec-fetch-mode":"cors","sec-fetch-site":"same-origin","content-length":"0"},"remoteAddress":"172.18.0.1","userAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:106.0) Gecko/20100101 Firefox/106.0","referer":"http://localhost:5642/app/dev_tools"},"res":{"statusCode":200,"responseTime":59},"message":"POST /api/console/proxy?path=_mapping%3Fpretty%3Dfalse&method=GET 200 59ms"}
{"type":"log","@timestamp":"2022-11-15T01:56:13+00:00","tags":["info","status"],"pid":8,"message":"Kibana is now available (was degraded)"}
{"type":"log","@timestamp":"2022-11-15T02:09:43+00:00","tags":["info","status"],"pid":8,"message":"Kibana is now degraded (was available)"}
{"type":"response","@timestamp":"2022-11-15T02:09:48+00:00","tags":["access:console"],"pid":8,"method":"post","statusCode":200,"req":{"url":"/api/console/proxy?path=_aliases%3Fpretty%3Dfalse&method=GET","method":"post","headers":{"host":"localhost:5642","user-agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:106.0) Gecko/20100101 Firefox/106.0","accept":"text/plain, */*; q=0.01","accept-language":"en-US,en;q=0.5","accept-encoding":"gzip, deflate, br","referer":"http://localhost:5642/app/dev_tools","kbn-xsrf":"kibana","origin":"http://localhost:5642","connection":"keep-alive","sec-fetch-dest":"empty","sec-fetch-mode":"cors","sec-fetch-site":"same-origin","content-length":"0"},"remoteAddress":"172.18.0.1","userAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:106.0) Gecko/20100101 Firefox/106.0","referer":"http://localhost:5642/app/dev_tools"},"res":{"statusCode":200,"responseTime":34},"message":"POST /api/console/proxy?path=_aliases%3Fpretty%3Dfalse&method=GET 200 34ms"}
{"type":"response","@timestamp":"2022-11-15T02:09:48+00:00","tags":["access:console"],"pid":8,"method":"post","statusCode":200,"req":{"url":"/api/console/proxy?path=_template%3Fpretty%3Dfalse&method=GET","method":"post","headers":{"host":"localhost:5642","user-agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:106.0) Gecko/20100101 Firefox/106.0","accept":"text/plain, */*; q=0.01","accept-language":"en-US,en;q=0.5","accept-encoding":"gzip, deflate, br","referer":"http://localhost:5642/app/dev_tools","kbn-xsrf":"kibana","origin":"http://localhost:5642","connection":"keep-alive","sec-fetch-dest":"empty","sec-fetch-mode":"cors","sec-fetch-site":"same-origin","content-length":"0"},"remoteAddress":"172.18.0.1","userAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:106.0) Gecko/20100101 Firefox/106.0","referer":"http://localhost:5642/app/dev_tools"},"res":{"statusCode":200,"responseTime":43},"message":"POST /api/console/proxy?path=_template%3Fpretty%3Dfalse&method=GET 200 43ms"}
{"type":"response","@timestamp":"2022-11-15T02:09:48+00:00","tags":["access:console"],"pid":8,"method":"post","statusCode":200,"req":{"url":"/api/console/proxy?path=_mapping%3Fpretty%3Dfalse&method=GET","method":"post","headers":{"host":"localhost:5642","user-agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:106.0) Gecko/20100101 Firefox/106.0","accept":"text/plain, */*; q=0.01","accept-language":"en-US,en;q=0.5","accept-encoding":"gzip, deflate, br","referer":"http://localhost:5642/app/dev_tools","kbn-xsrf":"kibana","origin":"http://localhost:5642","connection":"keep-alive","sec-fetch-dest":"empty","sec-fetch-mode":"cors","sec-fetch-site":"same-origin","content-length":"0"},"remoteAddress":"172.18.0.1","userAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:106.0) Gecko/20100101 Firefox/106.0","referer":"http://localhost:5642/app/dev_tools"},"res":{"statusCode":200,"responseTime":103},"message":"POST /api/console/proxy?path=_mapping%3Fpretty%3Dfalse&method=GET 200 103ms"}
{"type":"log","@timestamp":"2022-11-15T02:10:32+00:00","tags":["info","status"],"pid":8,"message":"Kibana is now available (was degraded)"}
{"type":"log","@timestamp":"2022-11-15T02:11:59+00:00","tags":["info","status"],"pid":8,"message":"Kibana is now degraded (was available)"}
{"type":"log","@timestamp":"2022-11-15T02:15:14+00:00","tags":["info","status"],"pid":8,"message":"Kibana is now available (was degraded)"}
{"type":"log","@timestamp":"2022-11-15T02:19:08+00:00","tags":["info","status"],"pid":8,"message":"Kibana is now degraded (was available)"} With a In Kibana 8.x this {"kibana":{"usageCounters":{"results":[{"id":"uiCounter:01062022:count:index_management:index_delete","type":"usage-counters","updated_at":"2022-06-01T16:52:44.190Z","references":[],"version":"WzE5NDQ3OCw2XQ==","attributes":{"domainId":"uiCounter","counterName":"index_management:index_delete","counterType":"count","count":5}}]}},"ecs":{"version":"8.0.0"},"@timestamp":"2022-06-01T16:52:45.172+00:00","message":"StorecountersintosavedObjects","log":{"level":"DEBUG","logger":"plugins.usageCollection.usage-collection.usage-counters-service"},"process":{"pid":20},"trace":{"id":"REDACTED"},"transaction":{"id":"REDACTED"}}
{"http":{"request":{"id":"unknownId","method":"POST","headers":{"REDACTED":true}},"response":{"body":{"bytes":228},"status_code":200,"headers":{"REDACTED":true}}},"url":{"path":"/.kibana_task_manager/_update_by_query","query":"ignore_unavailable=true&refresh=true"},"ecs":{"version":"8.0.0"},"@timestamp":"2022-06-01T16:52:45.350+00:00","message":"200-228.0B\nPOST/.kibana_task_manager/_update_by_query?ignore_unavailable=true&refresh=true\\n{\"query\":{\"REDACTED\":true}}","log":{"level":"DEBUG","logger":"elasticsearch.query.data"},"process":{"pid":20},"trace":{"id":"redacted"},"transaction":{"id":"redacted"}} To add to the confusion here, both the 7.x and 8.x standards match the same |
I've made a couple of minor tweaks recently that might help this situation. The format elements can now have a Using the example from @crc-smcleod, I've created this format: {
"$schema": "https://lnav.org/schemas/format-v1.schema.json",
"issue1065_log": {
"json": true,
"title": "format for issue #1065",
"level": {
"error": "error",
"info": "update"
},
"level-field": "status",
"body-field": "message",
"line-format": [
{
"field": "timestamp"
},
" ",
{
"field": "status",
"auto-width": true
},
" ",
{
"field": "image",
"min-width": 9,
"default-value": "-"
},
" ",
{
"field": "image_date",
"min-width": 24,
"default-value": "",
"suffix": " "
},
{
"field": "mime",
"auto-width": true,
"default-value": "",
"suffix": " "
},
{
"field": "size",
"auto-width": true,
"default-value": ""
},
{
"field": "message",
"default-value": ""
}
],
"timestamp-field": "timestamp",
"value": {
"timestamp": {
"kind": "string"
},
"status": {
"kind": "string"
},
"image": {
"kind": "string"
},
"image_date": {
"kind": "string"
},
"mime": {
"kind": "string",
"identifier": true
},
"size": {
"kind": "integer"
},
"message": {
"kind": "string"
}
}
}
} The following screenshot shows what things look like with this format and the above example log messages: Here's what it looked like before:
@VimCommando The format detection for JSON-lines files has been also been improved, so I think you can write two different format files that will separately recognize kibana7 and kibana8 even though the filenames are the same. The detection now tries to find a format that matches the most fields in the |
I think the conditional field functionality is good enough for now, going to close this out. Open a new feature request for improvements to that. |
Description
Would be great to have lnav able to handle different line-formats within the same json formatted file.
context
Apps usually integrate multiple components that have different json schema.
All components usually log to the same file or STDOUT usually merged in one uniq logfile by systemd.
proposition
We could use the module-field as identifier to distinguish message from one component to another.
The text was updated successfully, but these errors were encountered: