---
title: "Create an alert rule with query language | Grafana Labs"
description: "Build a Grafana alert rule in Code mode — write a PromQL error-rate query, set a condition, add labels, configure evaluation and notifications, and save."
---

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

# Create an alert rule with query language

Welcome! In this learning path, you build a Grafana alert rule by writing the query yourself in **Code mode**, instead of picking it from menus.

You’ll open a new alert rule, write a PromQL query that measures QuickPizza’s error rate, set a threshold, add labels and a folder, choose a contact point, and save.

## What you’ll learn

By the end of this path, you can:

- Tell when Code mode is a better fit than Builder mode
- Write a PromQL query that calculates a percentage
- Set a threshold that decides when the alert fires
- Organize an alert with a folder and labels for later filtering
- Control how often Grafana checks the rule
- Handle no-data and error cases so the alert stays useful
- Send the alert to a contact point with a helpful message

## Before you begin

You need:

- A Grafana Cloud account. To sign up, refer to [Grafana Cloud](/signup/cloud/connect-account).
- Permission to create alert rules.
- Some familiarity with PromQL. If PromQL is new to you, try [Create your first alert rule](/docs/learning-paths/alerting-first-rule/) first. It uses Builder mode, so you don’t need to write any query.

The next milestone installs **QuickPizza**, a demo pizza shop that generates real metrics. Querying it doesn’t count toward your Grafana Cloud usage.

## Troubleshooting

If you get stuck, we’ve got your back! Where appropriate, troubleshooting information is just a click away.

## More to explore

After you save your first rule, explore silences to suppress notifications during planned maintenance, and learn how to configure contact points and notification policies in depth.
