# BlackBox Exporter Calculate Percentage Status Codes

**URL:** <https://discuss.prometheus.io/t/blackbox-exporter-calculate-percentage-status-codes/377>\
**Category:** Exporters and Metrics\
**Created:** [July 13, 2021, 1:59pm UTC](https://discuss.prometheus.io/t/blackbox-exporter-calculate-percentage-status-codes/377 "2021-07-13T13:59:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![luca.chana](https://avatars.discourse-cdn.com/v4/letter/l/e9a140/32.png) [@luca.chana](https://discuss.prometheus.io/u/luca.chana)\
**Post date:** [July 13, 2021, 1:59pm UTC](https://discuss.prometheus.io/t/blackbox-exporter-calculate-percentage-status-codes/377/1 "2021-07-13T13:59:20Z")

</div>

Hi  
I’m trying to calculate the percentage of 200 & 500 status codes.  
I have tried a few things including:

```auto
avg(probe_status_code{instance="$target"} != 200) / (probe_status_code{instance="$target"} == 200) * 100

```

When I do this I get no data and when I try avg\_over\_time I get the error instant vector given for range.

Has anyone been able to do this yet? Do I need to do two queries then transform in Grafana?

Thanks

---

<div class="post-metadata">

**Author:** ![luca.chana](https://avatars.discourse-cdn.com/v4/letter/l/e9a140/32.png) [@luca.chana](https://discuss.prometheus.io/u/luca.chana)\
**Post date:** [July 19, 2021, 12:46pm UTC](https://discuss.prometheus.io/t/blackbox-exporter-calculate-percentage-status-codes/377/2 "2021-07-19T12:46:14Z")

</div>

Bump please someone if you know how to do this?
