Gauge for percentage error rate not showing correct calculation

I am trying to visualize the percentage of requests that resulted in error (minute by minute) via a Grafana gauge but the Gauge is not showing the correct value. For example when I execute 10 requests within a 1 minute interval - where 5 of those requests result in HTTP 200 and 5 result in HTTP 500 then I expect the Gauge to show 50% error percentage. However the value stays at 100% regardless that I have been sending successful and unsuccessful requests to the API :

This is the corresponding query :

100 * (sum(sum_over_time(total_requests_gauge{status_code!="200"}[1m]))/ on() group_left() sum(sum_over_time(total_requests_gauge[1m])))

I have configured the Gauge unit to Percent :

image

Prometheus is scrapping the metrics correctly at http://localhost:9090 as well as the API endpoint at http://localhost:80/metrics

I also have an endpoint (.Net Core 5) that always returns error responses :

[AllowAnonymous]
    [HttpPost("problem")]
    public IActionResult Problem([FromBody] RegisterModel model)
    {
        //always returns HTTP 500 error      
            return Problem();
    }

Grafana Version : 9.3.2

Hi @edtshuma,

Thanks for opening this post.

This sounds more like a Prometheus query issue rather than the Gauge Panel, therefore moved it to the Prometheus Category.

Also, saw that you already found a solution from another resource so posting it here to make the post complete and helpful for other community users :slight_smile: