tilt icon indicating copy to clipboard operation
tilt copied to clipboard

ability to render a server's json logs as human readable in Tilt

Open landism opened this issue 3 years ago • 8 comments

Describe the Feature You Want

Some servers write their logs in json so that they're machine-readable. When viewing them in Tilt, it'd be nice to be able to massage the output a bit to make them more human-readable.

Current Behavior

Tilt just logs the raw output (json) logged by the server.

Why Do You Want This?

Formatted logs are easier to read than JSON logs.

Additional context

  • GCP log explorer lets you pull fields out of JSON logs - https://cloud.google.com/logging/docs/view/logs-viewer-interface

landism avatar May 24 '21 17:05 landism

fwiw, when people ask for this, I usually point them to the tilt logs command

https://docs.tilt.dev/cli/tilt_logs.html

Then you can pipe it to your favorite log processor (like jq or humanlog)

I guess this bug is about adding easier ways to do this from the web UI?

nicks avatar May 24 '21 19:05 nicks

Yeah, specifically we're interested in the logs being human readable in the web UI

jbadlato avatar Aug 04 '22 22:08 jbadlato

+1, having this available in the web UI will be a really nice QoL improvement. When you're dealing with a bunch of microservices and wish to see the logs on each of them individually, clicking a single button on the UI is a lot faster than typing out tilt logs and the name of the pod you're interested in

huangzou70 avatar Aug 05 '22 14:08 huangzou70

Would choice of log formatting be part of the resource definition or would it be some additional configuration that each developer would make?

dspasojevic avatar Sep 16 '22 03:09 dspasojevic

@dspasojevic Personally, I think it being part of the resource definition would be sufficient. I don't think anyone wants to read the JSON logs in the UI (anything you use the JSON representation for is more than likely happening outside the UI)

jbadlato avatar Sep 16 '22 13:09 jbadlato

Wanted to add that this is a feature I could really use. Especially being able to formatted json logs through the UI. Only being able to view the raw output of the json logs is currently a bit of a pain point for our team.

eric-lammers-form3 avatar Dec 07 '22 22:12 eric-lammers-form3

Also wanted to add that a UI component for this would be the best, but even when using tilt logs for a resource with multiple containers, piping logs to jq is still non-trivial. Unless I'm missing an option somewhere to prevent adding container prefixes, log lines come out as [container_name] <json log> which itself is not valid JSON.

The prefixes can be filter out with an extra pipe through awk, but still, something user-friendly to remove these prefixes so piping JSON logs to jq was easy would be amazing.

joeellis avatar Feb 06 '23 13:02 joeellis