
Is your feature request related to a problem? Please describe.
Viewing a pod's logs, the kubernetes timestamp is not displayed nor a way to toggle it on or off
Describe the solution you'd like
It will be nice to be able a way to display the timestamps of logs in the log view. Many apps in pods do not write out the timestamps as part of the log message, relying on the timestamps saved by kubernetes. The timestamps I'm referring to is what you get when you view logs via "kubectl logs --timestamps". I suggest a simple toggle command ("t" makes sense) while in the log view. I do realise that because some apps print timestamps as part of their logs, it would not make sense to view the kubernetes timestamps by default, but maybe also give us a way to default the timestamps feature to "on" via the config.yml
Describe alternatives you've considered
The wiki (at https://github.com/derailed/k9s#plugins) gives us a way to view logs in a custom way via a custom shortcut, using plugins. But it would be nice if we get a way to view timestamps in the default logs view.
@mot256 Thank you Francois for this issue! Agreed!! It makes perfect sense to have this option readily available in the log view.
This is done in one of the latest releases? Since I now see UTC timestamps in front of my logs, but no way to toggle them on/off?
@mycrEEpy this is referring to the datetime timestamp you get when you log a pod with --timestamps Currently the latest version of k9's doesn't support this. It would be nice to be able to configure this in the k9s config.yml otherwise, like @mot256 suggested you could create a plugin to add this functionality to k9s. Here's what I'm currently using to do it
# $HOME/.k9s/plugin.yml
plugin:
timestamp:
shortCut: Ctrl-L
description: log pod --timestamps
scopes:
- po
command: kubectl
background: false
args:
- logs
- --timestamps
- -f
- $NAME
- -n
- $NAMESPACE
- --context
- $CONTEXT
@mot256 @mycrEEpy @kcarra Thank you all for your feedback! I am working on this now and log timestamps will be available in the next drop natively in k9s.
I thought I saw them in an early 0.17.x release. Now they are gone ¯\_(ツ)_/¯
@mycrEEpy you could be right. Did a really quick search of the repo and it looks like maybe they were configurable at one point https://github.com/derailed/k9s/commit/bdd4ecff200e141911a8c34d4c4cfb0b9be5396c#diff-6f0b2aacae14122d47e4ee567ff3279c
@mot256 @mycrEEpy @kcarra Fixed v0.18.0!
Thanks for this change @derailed
Much appreciated!
Most helpful comment
@mot256 @mycrEEpy @kcarra Fixed v0.18.0!