简体   繁体   中英

How to calculate uptime % or Downtime % in Prometheus Grafana

How to calculate uptime in % already in prometheus grafana using below query process_uptime_seconds{application="$application", instance="$instance", job!="jobid"}

For up could you do something like this?

(1 - avg_over_time(up[1d])) * 86400

That would give you the number of seconds down over the last day.

You wouldn't want to use that metric to calculate uptime. The fact that the number reset, just means that the process restarted.

Instead I would recommend using the up metric that Prometheus creates automatically. Then you would want to group it by application and ignore the instance and jobid.

Something like:

sum(up{application="$application"} == 1) by (application) /
 sum(up{application="$application"}) by (application)

That way you are dividing how many are succeeding in being up by the total of that application.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM