---
title: "Build an alert with code | Grafana Labs"
description: "When to choose Code mode over Builder, plus a hands-on Path for writing PromQL and creating a silence."
---

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

## Build an alert with the Code mode

You just built an alert in **Builder** mode. **Code** mode follows the same rule flow. The difference is how you write the query: you type PromQL instead of picking the metric and operations from menus in the UI.

| Use case                                           | Recommended mode |
|----------------------------------------------------|------------------|
| Standard metric, labels, and common operations     | Builder          |
| Complex nested expressions or exact syntax control | Code             |
| Team members new to PromQL                         | Builder          |

Start in Builder when you’re learning. Switch to Code when you need more control than Builder can express clearly.

## Path

This Path walks you through writing the alert query in PromQL, then creating a silence to suppress notifications during maintenance.

Learning path

#### First alert rule with query language

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.

14 min

Intermediate

Docs &amp; blog posts

#### Open in Grafana Cloud

Complete this learning path directly in your Grafana Cloud stack with an interactive learning experience.

[Open in Grafana Cloud]()

[View on website](/docs/learning-paths/alerting-query-language/)
