You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
I have many log lines with labels like duration=1000 for 1 second, and duration=3600000 for 1 hour. I'd like to have this pretty printed into either a hh:mm:ss kind of format, or even something like 1h 30m 1.123s
Currently the closest I've gotten is to use | label_format duration_pretty={{ if .duration }}{{ .duration | printf "%sms" | duration | printf "%.3f" }}s{{ end }}`
Describe the solution you'd like
I would like a template function that's exactly the reverse of duration_seconds, i.e. I would like it to take a number (of seconds), and convert it into a humanized time duration.
Describe alternatives you've considered
This is the current workaround I've arrived at:
| label_format duration_h=`{{ if .duration }}{{ div .duration 3600000 }}{{ end }}`, duration_m=`{{ if .duration }}{{ div .duration 60000 }}{{ end }}`, duration_s=`{{ if .duration }}{{ div .duration 1000 }}{{ end }}`
| label_format duration_pretty=`{{ if .duration }}{{ if .duration_h | int }}{{ .duration_h | int | printf "%d" }}h {{ end }}{{ if mod .duration_m 60 }}{{ mod .duration_m 60 | printf "%d"}}m {{ end }}{{ mod .duration_s 60 | printf "%d"}}.{{ mod .duration 1000 | printf "%03d"}}s{{ end }}`
Additional context
N/A
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem? Please describe.
I have many log lines with labels like
duration=1000
for 1 second, andduration=3600000
for 1 hour. I'd like to have this pretty printed into either ahh:mm:ss
kind of format, or even something like1h 30m 1.123s
Currently the closest I've gotten is to use
| label_format duration_pretty=
{{ if .duration }}{{ .duration | printf "%sms" | duration | printf "%.3f" }}s{{ end }}`Describe the solution you'd like
I would like a template function that's exactly the reverse of duration_seconds, i.e. I would like it to take a number (of seconds), and convert it into a humanized time duration.
Describe alternatives you've considered
This is the current workaround I've arrived at:
Additional context
N/A
The text was updated successfully, but these errors were encountered: