dozzle icon indicating copy to clipboard operation
dozzle copied to clipboard

Support for JSON logs

Open amir20 opened this issue 2 years ago • 8 comments

This pull request adds JSON support.

  • [x] Show all fields when no fields are selected
  • [x] Allow adding and removing json fields
  • [x] Save field list to localstorage
  • [ ] Support search when JSON is enabled
  • [ ] Highlight text when searching
  • [ ] Filter with json keys

amir20 avatar Jun 01 '22 02:06 amir20

JSON.parse() is very memory hungry for polymorphic objects. If there are a lot of them, there may be memory leaks. Tell me, please, will these JSON-events have a standard structure or a non-permanent one?

vanodevium avatar Jun 02 '22 13:06 vanodevium

JSON.parse() is very memory hungry for polymorphic objects. If there are a lot of them, there may be memory leaks.

I read a lot about JSON.parse(). Seems like for large json objects, it does eat a lot of memory. For smaller objects, it is much more efficient. I haven't found any proof of it. But I have only tested locally.

Tell me, please, will these JSON-events have a standard structure or a non-permanent one?

Unfortunately, there isn't a standard structure. Why would there be? The JSON objects are generated by the logging system for each container. They can be anything. At first I tried to use protobuf or other formats that would make the parsing more efficient. But after some research, for schemaless data, I found it didn't matter.

I would love to get more feedback on this feature. JSON logs are very powerful and Dozzle only treats it as text. I was thinking of even parsing all the json, pushing it to some client side database for better experience.

amir20 avatar Jun 02 '22 16:06 amir20

Firstly, you make a cool tool! I like it! Thank you!

Secondly, what kind of user experience will parsing these logs bring? As an example, key search? Or highlight? Or just pretty screen output?

about the JSON.parse(): I also have experience using it with a large flow of messages, it is very slow...

vanodevium avatar Jun 02 '22 16:06 vanodevium

Right now this PR brings the ability to show only specific JSON fields. See screenshot which is work in progress.

Screen Shot 2022-06-02 at 10 08 03 AM

Search by key would be a natural follow up. I think that's technically harder.

amir20 avatar Jun 02 '22 17:06 amir20

Just ideas, something might work:

  1. Enable compression (gzip) for SSE and return already parsed and pretty formatted JSON
  2. Show as usual text as default view, but when user click on logline - reformat code using JSON.parse()

Or did I misunderstand you at all?

vanodevium avatar Jun 02 '22 18:06 vanodevium

Enable compression (gzip) for SSE and return already parsed and pretty formatted JSON

Does the pretty format make a difference?

Show as usual text as default view, but when user click on logline - reformat code using JSON.parse()

I was trying to be smarter and only render the JSON when the log is in with view. It turned out to be hard and I labeled it as premature optimization. :) I am going to look to see how this performs and come back on doing anything to improve speed.

amir20 avatar Jun 02 '22 18:06 amir20

Awesome! Sounds good.

Also, this feature can be enabled from startup configuration by the way :)

Do parse JSON OR Do not parse JSON

vanodevium avatar Jun 02 '22 18:06 vanodevium

Fixed some bugs and scrollback works now.

amir20 avatar Jul 12 '22 18:07 amir20