Write your query in Code mode
Your alert watches how often QuickPizza’s server fails. You want it to fire when more than 5 in every 100 requests fail.
You switch to Code and write PromQL so the full ratio is one clear expression.
What the query does:
quickpizza_server_http_requests_totalcounts every request.rate(...[5m])converts that count to a per-second rate over 5 minutes.{status=~"5.."}keeps only 5xx failures.- Dividing failed by all requests, then multiplying by 100, gives a percentage.
Reopen New alert rule if installing QuickPizza redirected you away from the form.
Confirm Name is QuickPizza high error rate after reopening the form.
Choose grafanacloud-play-prom as the data source.
Select Code on the mode toggle.
Enter the error-rate query in Code:
100 * sum(rate(quickpizza_server_http_requests_total{status=~"5.."}[5m])) / sum(rate(quickpizza_server_http_requests_total[5m]))Click Run queries.
The query reports QuickPizza’s error rate as a percentage. Next, you set the threshold and recovery while you’re still in this section.