derailed / k9s

🐶 Kubernetes CLI To Manage Your Clusters In Style!
https://k9scli.io
Apache License 2.0
27.56k stars 1.74k forks source link

Log format with timestamps #1015

Open Makovec opened 3 years ago

Makovec commented 3 years ago




Is your feature request related to a problem? Please describe. When I switch to Toggle Timestamp mode in pod logs (my default, love it) I'd like to remove duplicate time in the log line. See example below.

Describe the solution you'd like Standard log looks like this:

time="2021-01-19T20:31:31Z" level=info msg="login successful: <truncated>

when I switch to timestamp, it looks this way:

2021-01-19T20:31:31.000375786Z time="2021-01-19T20:31:31Z" level=info msg="login successful: <truncated>

So there is two times actual time. I'd like to see something like:

2021-01-19T20:31:31.000375786Z level=info msg="login successful: <truncated>

without extra time="2021-01-19T20:31:31Z"

Additional context I understand that there are more variants of log lines, but I believe that the most frequent are:

  1. time="2021-01-19T20:31:31Z" level=info msg="login successful <truncated>
  2. 10.10.10.10 - - [19/Jan/2021:20:36:07 +0000] "GET /api/v1/addons HTTP/1. NCSA?

so probably let's add it by frequency/request.

Regards, David

derailed commented 3 years ago

@Makovec Thank you David for this great issue. That might be a bit tougher to decipher a time stamp for custom logs as it might be at different position, different format or simply a timestamp not related to log time for some other entity. That said, I did notice too on some workloads but it will vary by installation and tech stack used for logging, to my greatest chagrin...

TiansuYu commented 1 month ago

I would like to add a feature request for customize formatting of the timestamp k9s provided itself, such that users can add e.g.

k9s:
  timestamp:
     format_string: 'YYYY-MM-DD:HH:MM:SS'

to custom the output of the timestamp.

Or at least I can configure it to reduce the precision to seconds not milliseconds.