-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Add JSON parsing to Log View #2973
base: master
Are you sure you want to change the base?
Add JSON parsing to Log View #2973
Conversation
@r-oldenburg Thank you for this update Roland! I like the concept but it would require a lot of TLC to map out the various logging strategies to pull the required fields. That imho should live outside the main k9s config. Similarly to k9s plugins this would give us a way to quickly create and ingest contributions. |
Hey there @derailed, Sorry for this post being so long. I hope you find the time to read it... :-D TL;DR: You are absolutely right. Only the aspect performance may not really an issue. But hey, maybe I am missing something. Now the long version: If I get you right, your concerns are
Please let me elaborate on them. First some general thoughts:
Here an example for some log messages from MongoDB:
Now in most cases you don't need all the fields. What you actually need would most likely be this:
Another example from java/spring:
Here the arguments in the message are even given in a separate list property (arguments). Which makes it even harder to read and distinguish the log messages. Timestamp is just a number, and so on... You actually would want to see this (leading datetime taken from the timestamp field):
The common ground for all logs usually is: Time, Log-Level and the Message That way you can achieve to read the log in a regular "logfile style" while still having JSON logging turned on. For our k8s ENVs this turned out to be very(!) helpful. Now about your (perfectly reasonable) concerns (in reverse order):
I would be happy to adjust the code according to your guidance. |
I'm glad to find that I'm not the only one struggling with structured logging as well. Hope this can be merged and released soon 🚀 |
Hey there,
I wanted to share this contribution to this amazing project.
First thing: I am not a native GO programmer. SORRY, if I did break anything or violated any best practices / code conventions or whatever. Feel free to give such feedback.
We just changed the logging in our k8s deployments to JSON in order to make use of structured logging. Reading those in k9s is a pain, so I searched for solutions. And only found plugin solutions that are not giving the same UX as the usual Log View.
The current log UX in k8s is amazing, so I started experimenting with "jq" calls from within k9s. And eventually I found "gojq" which now even allows running without a "jq" installation on the system.
The main idea is to extract 3 fields: datetime, log level, message
Features:
Example Templates
... that I can provide (as follows):
Screenshots
Classic log view
JSON decode turned on
Edit/select templates