Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Im trying to calculate uptime in Grafana based on the successful responses from Prometheus blackbox exporter

I've tried counting the number of probe_success and multiplying it by the probe interval trying to get uptime in seconds and setting the value type to the total. the issue is the minimum step changes as the time frame changes not giving us a correct reading and nulling this option. What we are actually trying to do is get the percentage uptime based on successful probes in the time frame set for the dashboard. We are using singlestat to show the percentage

(probe_success{instance="www.google.com:443",job="clienttest"})*15

We tried dividing the value by an exporter its self to try to get a percentage that would also scale to no avail.

sum(probe_success{instance="www.google.com:443",job="clienttest"}) / sum(probe_success{instance="self",job="clienttest"}) *100
like image 286
David Aylward Avatar asked Mar 07 '18 16:03

David Aylward


1 Answers

For a singlestat panel what you want to do is use just probe_success{instance="www.google.com:443",job="clienttest"} as the expression, and under options make sure you are using the Average aggregation.

On the PromQL side you can also do avg_over_time(probe_success[1h]), see this blog post.

like image 134
brian-brazil Avatar answered Oct 22 '22 06:10

brian-brazil