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_total counts 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.
  1. Choose grafanacloud-play-prom as the data source.

  2. Click Code on the mode toggle.

  3. 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.


page 5 of 12