Add new LogFormat: StructuredJSON#1951
Conversation
This format is intended as an imporvement over the JSON format. It tries to improve in these ways: - Explicitly encode log level as a key in the main JSON object logged - Encode field values as key-value pairs in the main JSON object Encoding logs like this makes it easy for external tools like fluent-bit and elasticsearch to understand the log level and the fields and index them as such without requiring bonanza to be present while processing logs.
jschaul
left a comment
There was a problem hiding this comment.
This just adds the new log format, right? But doesn't turn it on anywhere yet - how/where is it turned on to log that way?
The first part, the log level - could that not also be a separate structural element rather than the first item in the list of msgs? Or do you configure fluent-bit to parse the log level as first element?
Yes, it only adds a new log format. I will turn it on in our federation environments as a test. If all looks fine after a month or so, I will propose that we make it the default.
The way tinylog works, it sends all the logs as |
| let structuredJSON = toStructuredJSONOutput logElems | ||
| in fromEncoding . toEncoding $ | ||
| object | ||
| ( [ "level" Aeson..= lvl, |
There was a problem hiding this comment.
@jschaul This line adds the level to the final JSON.
|
Turns out this doc is a lie. The actual |
|
I also created an issue upstream: https://gitlab.com/twittner/tinylog/-/issues/5 |
This format is intended as an imporvement over the JSON format. It tries to
improve in these ways:
Explicitly encode log level as a key in the main JSON object logged
Encode field values as key-value pairs in the main JSON object
Encoding logs like this makes it easy for external tools like fluent-bit and
elasticsearch to understand the log level and the fields and index them as such
without requiring bonanza to be present while processing logs.
https://wearezeta.atlassian.net/browse/FS-62
Checklist
changelog.d.