Closed bn-darindouglass-zz closed 3 years ago
Hi Darin,
In my design, the core should have zero dependencies to avoid conflicts as much as possible. At the moment has only the ring-buffer which I'm thinking to embed.
Adding Json formatter to the console printing would require cheshire
(or similar) which in turn would add jackson
which is a very popular library and very likely to conflict with other dependencies in your projects.
Minimising the risk of dependency clash is a primary design goal for this library, this is the reason why I haven't added this feature in the ConsolePublisher.
Another aspect is that the Console publisher is designed for development purpose only. In the past, I had issues with a similar setup of yours and I've experienced the loss of data. High-volume systems which produce loads of logs could cause the system to discard as much as 40-60% of logs because they can't keep up with the collection, parsing and indexing. The problem was fixed by publishing directly to the end system.
For example, in your case, you could write a simple publisher which sends the data directly to Sumologic HTTP endpoints and takes advantage of batching apis.
Alternatively, if you think that it is still preferable to log to the console, I would recommend writing a custom publisher as described here: How to write custom publishers. Basically, you can take the first example and add the JSON formatting. To start your new publisher you can use the Custom publishers which dynamically loads the publisher or the Inline publishers config.
If this is something that many people require I could think of adding this to the Advanced Console publisher which it would be separated from the core.
Thanks for the quick reply!
I honestly forgot your json
namespace wasn't included in core. Keeping jackson
out of the dependency tree does make a lot of sense, given its well-earned reputation.
We actually do have our own ConsoleJsonPublisher
but, given it's essentially a copy/paste of the main ConsolePublisher
, we figured we'd submit the request to get it into core. :)
You gave some nice insights on the console logging situation: though given the kube standard I mentioned, stdout logging doesn't seem to be strictly a non-production thing anymore.
All-in-all, we've started to replace our home-grown structured logging library with a thin-wrapper around mulog
. It's been fairly nice to work with, thanks for all the work!
Great, I'm glad that it is working well for you... it would be nice hearing some experience reports in a couple of months.
Please let me know how the JSON Console publisher is working for you and if it is something that more people need I will add it to the AdvancedConsolePublisher.
Quick thought: while we can't have the JSON publisher in core, we could, however, have it in mulog-json
as :type :console-json
or some such.
mulog-json
is just an internal library to manage to common handling
of JSON marshalling/unmarshalling. It is just to avoid repeating
the same code over every single publisher that need JSON handling.
The AdvancedConsolePublisher will have a bunch of features that couldn't be added in the ConsolePublisher because of the dependency restriction. So the correct place to add the JSON formatting would be there.
The AdvancedConsolePublisher will also contain ansi-terminal coloring (@simion-iulian is currently working on it).
As soon as the Simion's PR is ready I will add the JSON formatting as well.
Hi,
this option is available in the master
branch and it will be released in the next couple of days.
https://github.com/BrunoBonacci/mulog/blob/master/doc/publishers/advanced-console-publisher.md
Awesome! Thanks for the work on this.
Apps in Kube tend to print their logs to stdout which allows Kube to handle logging in a centralized way. Many log aggregation services can query these logs and ingest them into their system. If these logs are in JSON format, the services (e.g. sumologic) automatically decode them and make their fields available for consumption in their app.
It would be an improvement if
mulog
provided a way to print JSON logs to the console. Adding a:format :edn|:json
config (or similar) to theConsolePublisher
would be one way to provide this in common code and not require a new, custom publisher.