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 :
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