Path

Switch to Code mode and write a PromQL error-rate query for QuickPizza.

Estimated time: 1 min

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. Reopen New alert rule if installing QuickPizza redirected you away from the form.

  2. Confirm Name is QuickPizza high error rate after reopening the form.

  3. Choose grafanacloud-play-prom as the data source.

  4. Select Code on the mode toggle.

  5. Enter the error-rate query in Code:

    promql
    100 * sum(rate(quickpizza_server_http_requests_total{status=~"5.."}[5m])) / sum(rate(quickpizza_server_http_requests_total[5m]))
  6. 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.