1
votes

I'm trying to show system uptime as DD-HH-MM-SS format, doing it using common code wouldn't be an issue but I'm doing it using Prometheus (PromQL) and Grafana only, here's the PromQL query:

time()-process_start_time_seconds{instance="INSTANCE",job="JOB"}

I achieved the basic output I wanted, it shows me the process life time. The output for the query above gives me time in seconds (for instance 68003) and converts it to bigger time units (minutes, hours etc.), but in its decimal form:

decimal uptime

The 89 after the decimal point refers to 89% of an hour,about 53 minutes. That's not a really "intuitive" way to show time, I would have liked it to display a normal DD:HH:MM:SS presentation of that time like the following screenshot from a simple online tool that converts seconds to time:

regular uptime

Is there away to achieve it using only PromQL and Grafana configuration?

1

1 Answers

4
votes

You can achieve this using "Unit" drop-down in the visualization section and select your unit as duration with the hh:mm:ss format, as you can see in the screenshot.

enter image description here