---
title: "Build your query and set the condition | Grafana Labs"
description: "Build a Prometheus query and set the alert condition."
---

> For a curated documentation index, see [llms.txt](/llms.txt). For the complete documentation index, see [llms-full.txt](/llms-full.txt).

# Build your query and set the condition

You’ll build a query that watches QuickPizza for server errors, then confirm when the alert fires.

Use **Builder** mode instead of writing PromQL. Keep the condition as **Is above** **0**.

1. On the **New alert rule** page, choose the data source that holds the metric you want to alert on.
   
   **grafanacloud-play-prom** is filled in for you.
2. Optionally, toggle **Explain** on. Grafana describes each part of your query in plain language.
3. Confirm **Builder** is selected so you can build the query without writing PromQL.

You’ve prepared the query editor. Next, build the metric query.

1. In the **Metric** drop-down, paste `quickpizza_server_http_requests_total`, then select it from the list.
   
   This counter tracks HTTP requests for QuickPizza services and includes a response **status** label.
2. In the **Label filters** row, open the **Label** drop-down and select **status**.
3. Open the operator drop-down and change **=** to **=~** so one filter can match every 5xx status code.
4. In the **Select value** box, enter `5..`, then press Enter.
   
   That regex matches any three-digit status that starts with 5.

The metric is a counter that only increases. Add a range function to count new errors over the last 5 minutes. Optionally sum across services so the alert uses one total.

1. Click **+ Operations**. In the **Operations** drop-down, select **Range functions / Increase**, then set the **Range** to **5m**.
2. Optionally, click **+ Operations** again and select **Aggregations / Sum**.
3. Click **Run queries**.

Check that your query matches `sum(increase(quickpizza_server_http_requests_total{status=~"5.."}[5m]))` and that **Run queries** succeeds.

Next, confirm the alert condition.

1. In the **Alert condition** section, confirm **Is above** is selected and the value is **0**.
2. Click **Preview alert rule condition** to evaluate the condition against your query.
   
   The result may show **Normal** or **Firing**, depending on whether the query is above **0** right now.

Your query and alert condition are set. Next, you create a folder and add labels.
