System up time

27 views
Skip to first unread message

ritesh patel

unread,
Sep 22, 2022, 11:24:44 PM9/22/22
to promethe...@googlegroups.com
Hi All, 

I have prometheus running on docker, added around 1000+ hosts as a target. prometheus scraping metrics using telegraf. 

I have one metrics which name System up time. But metrics value is not showing as day and hours. I want total days and hours of syatem up and running. Exp- xx.xx.xx.xx hosts up since 23days 

Can someone help me to create promQL for that metrics to show value like days and hours system running 

Thanks and regards 
Ritesh patel 

Brian Candler

unread,
Sep 23, 2022, 3:33:20 AM9/23/22
to Prometheus Users
Metrics are always float64 values. How you present them to the user is up to the client appplication: e.g. if you were using Grafana, you'd tell Grafana to display the value in a human-readable time duration format.

You can do simple arithmetic in PromQL queries.  For example, if "sysUpTime" is a metric with units of 1/100ths of a second, then the following will convert it to days:

sysUpTime / 8640000

Here 3.5 would mean "3 days 12 hours".  Again, displaying it in such a format is down to the client making the query, because the query will just give you a number (or more precisely, a vector of numbers, since there may be multiple timeseries for the sysUpTime metric)
Reply all
Reply to author
Forward
0 new messages