Build your query

You’ll build an alert that watches the QuickPizza app for server errors. You’ll use Builder mode instead of using a query language.

  1. Choose the data source that holds the metric you want to alert on. For this tutorial, grafanacloud-play-prom is filled in for you — it’s the Prometheus data source from the QuickPizza tutorial data sources.

  1. Toggle Explain on. Grafana narrates what each part of your query does in plain English — a fast way to learn what you’re clicking without knowing PromQL syntax.

  1. Make sure Builder mode is selected. This mode lets you build the query without using PromQL.

  1. Copy quickpizza_server_http_requests_total from this step, paste it into the Metric drop-down, then select it from the list. This counter tracks every HTTP request QuickPizza’s services handle, labeled with the response status. It’s the raw material for the alert.

  1. In the Label filters row, open the Label drop-down and select status. The raw metric covers all requests — the status label lets you narrow it down.

  2. Open the operator drop-down and change = to =~. The =~ operator does a regex match, so one filter catches every 5xx code at once (500, 502, 503, and so on).

  3. In the Select value box, enter 5.., then press Enter. That regex matches any three-digit status starting with 5, so the query now returns only server errors.

  1. The metric is a counter that only goes up, so its raw value doesn’t tell you whether errors just happened. increase() fixes that. Click + Operations to open the picker.

  2. Select Range functions, then Increase. Set the range to 5m — the query now counts new errors in the last 5 minutes.

  1. Without Sum, you get one number per QuickPizza service — noisier, harder to read. Summing gives one total so the alert answers “is QuickPizza having errors anywhere?” Click + Operations again to open the picker.

  2. Select Aggregations, then Sum. Grafana wraps your increase() result in a single total across all services.

  1. Click Run queries to preview the data. You should see 0 while QuickPizza is healthy, jumping above zero when 5xx errors happen in the last 5-minute window. If the preview is empty, double-check the data source, metric name, and label filter.

  2. Your query now counts QuickPizza’s 5xx errors over the last 5 minutes. In the next milestone, you set the condition that fires the alert the moment that count goes above zero.


page 5 of 12