Documentationbreadcrumb arrow Learning pathsbreadcrumb arrow First alert rule with query language

Open in Grafana Cloud

Complete this learning path directly in your Grafana Cloud stack, or in the Grafana Play stack, with an interactive learning experience.

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.
  • Permission to create alert rules.
  • Some familiarity with PromQL. If PromQL is new to you, try Create your first alert 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.

Are you ready?