---
title: "Configure Grafana-managed alert rules | Grafana documentation"
description: "Configure Grafana-managed alert rules to create alerts that can act on data from any of our supported data sources"
---

# Configure Grafana-managed alert rules

Grafana-managed alert rules are the default way to create alert rules in Grafana.

Grafana-managed rules inherit their model from Prometheus Alerting and extend it with greater flexibility—such as multi-data source queries, expression-based transformations, advanced alert conditions, images in notifications, custom states, and more.

To create or edit Grafana-managed alert rules, follow the instructions below.

> Tip
> 
> For quick-start tutorials on key alerting features, see [Getting started with Grafana Alerting tutorials](/docs/grafana/latest/alerting/best-practices/tutorials/).

## Before you begin

Before you create Grafana-managed alert rules, review the following requirements and options.

### Supported data sources

Grafana-managed alert rules can query backend data sources when the data source’s `plugin.json` file sets `{"backend": true, "alerting": true}`.

Before you create an alert rule, verify that the data sources you plan to query are compatible and properly configured.

You can find the public data sources that support alert rules in the [Grafana Plugins directory](/grafana/plugins/data-source-plugins/?features=alerting).

### Alert rule limits in Grafana Cloud

In Grafana Cloud, the number of Grafana-managed alert rules you can create depends on your Grafana Cloud plan.

- Free Forever plan: You can create up to 500 free alert rules, with each alert rule having a maximum of 1000 alert instances.
- All paid plans: They have a soft limit of 2000 alert rules and support unlimited alert instances. To increase the limit, open a support ticket from the [Cloud portal](/docs/grafana-cloud/account-management/support/).

### Permissions

Only users with **Edit** permissions for the folder storing the rules can edit or delete Grafana-managed alert rules. Only admins can restore deleted Grafana-managed alert rules.

### Provisioning

Note that if you delete an alert resource created in the UI, you can no longer retrieve it.

To backup and manage alert rules, you can [provision alerting resources](/docs/grafana/latest/alerting/set-up/provision-alerting-resources/) using options such as configuration files, Terraform, or the Alerting API.

### Default versus Advanced options

Grafana Alerting provides multiple configuration options to support different alerting needs.

To simplify alert rule creation, some settings display a **Default** and an **Advanced** configuration view:

- [Define query and condition](#define-query-and-condition)
- [Configure notifications](#configure-notifications)

Use **Default** to create basic query conditions and route alerts directly to a contact point. Use **Advanced** for more complex query definitions, or to route alerts using notification policies.

You can switch between options at any time. After you create an alert rule, Grafana remembers your last selection and uses it as the default for the next rule.

If you prefer to always use advanced configuration, you can disable the **Default** modes by disabling the `alertingQueryAndExpressionsStepMode` and `alertingNotificationsStepMode` feature toggles.

## Set alert rule name

1. Click **Alerts &amp; IRM** -&gt; **Alert rules** -&gt; **+ New alert rule**.
2. Enter a name to identify your alert rule.
   
   This name is displayed in the alert rule list. It is also the `alertname` label for every alert instance that is created from this rule.

## Define query and condition

Define a query to get the data you want to measure and a condition that needs to be met before an alert rule fires.

The **Default** option allows to configure one query and one alert condition. The **Advanced** option allows multiple queries and expressions for more complex rule definitions.

Default options

1. Select a data source.
2. Add a [query](/docs/grafana/latest/alerting/fundamentals/alert-rules/queries-conditions/).
3. Add an [alert condition](/docs/grafana/latest/alerting/fundamentals/alert-rules/queries-conditions/#alert-condition).
   
   The **When** input includes the reducer function and the last input is the threshold.
4. Click **Preview** to verify.

Advanced options

1. Select a data source.
2. From the **Options** drop-down menu, specify a [time range](/docs/grafana/latest/dashboards/use-dashboards/#time-units-and-relative-ranges).
   
   Note that Grafana Alerting only supports fixed relative time ranges, for example, `now-24hr: now`. It doesn’t support absolute time ranges: `2021-12-02 00:00:00 to 2021-12-05 23:59:592` or semi-relative time ranges: `now/d to: now`.
3. Add a query.
   
   To add multiple [queries](/docs/grafana/latest/alerting/fundamentals/alert-rules/queries-conditions/), click **Add query**.
   
   All alert rules are managed by Grafana by default. If you want to switch to a data source-managed alert rule, click **Switch to data source-managed alert rule**.
4. Add one or more [expressions](/docs/grafana/latest/alerting/fundamentals/alert-rules/queries-conditions/#expression-queries).
   
   a. For each expression, select either **Classic condition** to create a single alert rule, or choose from the **Math**, **Reduce**, and **Resample** options to generate separate alert for each series.
   
   When using Prometheus, you can use an instant vector and built-in functions, so you don’t need to add additional expressions.
   
   b. Click **Preview** to verify that the expression is successful.
5. To add a [recovery threshold](/docs/grafana/latest/alerting/fundamentals/alert-rules/queries-conditions/#recovery-threshold), enable the **Custom recovery threshold** toggle and enter a value that defines when the alert should recover—transition to `Normal` state from the `Alerting` or `Pending` state.
   
   You can only add one recovery threshold, and it must be part of the alert condition.
6. Click **Set as alert condition** on the query or expression you want to set as your [alert condition](/docs/grafana/latest/alerting/fundamentals/alert-rules/queries-conditions/#alert-condition).

You can switch between **Default** and **Advanced** options at any time.

Switching from **Advanced** to **Default** may result in queries and expressions that can’t be converted. In this case, a warning message asks if you want to continue to reset to default settings.

If the [Default versus Advanced options](#default-versus-advanced-options) feature is not enabled in your Grafana instance, follow the **Advanced options** instructions.

## Set folder and labels

Organize your alert rule with a folder and set of labels.

In the **Labels** section, you can optionally choose whether to add labels to organize your alert rules and their notifications. For more details, refer to [alert rule labels](/docs/grafana/latest/alerting/fundamentals/alert-rules/annotation-label/#labels).

1. Select a folder or click **+ New folder**.
2. Add labels, if required.
   
   Add custom labels by selecting existing key-value pairs from the drop down, or add new labels by entering the new key or value.

## Configure alert evaluation behavior

Use [alert rule evaluation](/docs/grafana/latest/alerting/fundamentals/alert-rule-evaluation/) to determine how frequently an alert rule should be evaluated and how quickly it should change its state.

To do this, you need to make sure that your alert rule is in the right evaluation group and set a pending period time that works best for your use case.

1. Select an evaluation group or click **+ New evaluation group**.
   
   If you are creating a new evaluation group, specify the interval for the group.
   
   All rules within the same group are evaluated concurrently over the same time interval.
2. Enter a [pending period](/docs/grafana/latest/alerting/fundamentals/alert-rule-evaluation/#pending-period).
   
   The pending period is the period in which an alert rule can be in breach of the condition until it fires.
   
   After a condition is met, the alert goes into the **Pending** state. If the condition remains active for the duration specified, the alert transitions to the **Firing** state, else it reverts to the **Normal** state.
3. Optionally, set the [Keep firing for](/docs/grafana/latest/alerting/fundamentals/alert-rule-evaluation/#keep-firing-for) period.
   
   You can set the minimum amount of time that an alert remains firing after the breached threshold expression no longer returns any results. This sets an alert to a “Recovering” state for the duration of time set here. The Recovering state can be used to reduce noise from flapping alerts. Select “none” stop an alert from firing immediately after the breach threshold is cleared.
4. Turn on pause alert notifications, if required.
   
   You can pause alert rule evaluation to prevent noisy alerting while tuning your alerts. Pausing stops alert rule evaluation and doesn’t create any alert instances. This is different to [mute timings](/docs/grafana/latest/alerting/configure-notifications/mute-timings/), which stop notifications from being delivered, but still allows for alert rule evaluation and the creation of alert instances.
5. In **Configure no data and error handling**, you can define the alerting behavior and alerting state for two scenarios:
   
   - When the evaluation returns **No data** or all values are null.
   - When the evaluation returns **Error** or timeout.
   
   ### Configure no data and error handling
   
   Expand table
   
   | Configure        | Set alert state | Description                                                                                                                                                                                                                                                                                                |
   |------------------|-----------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
   | No Data          | No Data         | The default option for **No Data** events.  <br />Sets alert instance state to `Pending`, then `No Data` after the pending period.  <br />The alert rule immediately creates a new `DatasourceNoData` alert instance after evaluation, with the alert rule’s name, UID, and the data source UID as labels. |
   | Error            | Error           | The default option for **Error** events.  <br />Sets alert instance state to `Pending`, then ‘Error`after the pending period. <br/> The alert rule immediately creates a new`DatasourceError\` alert instance after evaluation, with the alert rule’s name, UID, and the data source UID as labels.        |
   | No Data or Error | Alerting        | Sets the alert instance state to `Pending` and then transitions to `Alerting` once the pending period ends. If you sent the pending period to 0, the alert instance state is immediately set to `Alerting`.                                                                                                |
   | No Data or Error | Normal          | Sets alert instance state to `Normal`.                                                                                                                                                                                                                                                                     |
   | No Data or Error | Keep Last State | Maintains the alert instance in its last state. Useful for mitigating temporary issues.                                                                                                                                                                                                                    |
   
   For more details, refer to [alert instance states](/docs/grafana/latest/alerting/fundamentals/alert-rule-evaluation/stale-alert-instances/) and [modify the no data or error state](/docs/grafana/latest/alerting/fundamentals/alert-rule-evaluation/nodata-and-error-states/#modify-the-no-data-or-error-state).
6. In **Configure no data and error handling**, you can also configure [Missing series evaluations to resolve](/docs/grafana/latest/alerting/fundamentals/alert-rule-evaluation/stale-alert-instances/#configure-missing-series-evaluations-to-resolve): how many consecutive evaluation intervals must pass without data before an alert instance is considered stale.

## Configure notifications

Configure who receives notifications when the alert rule fires.

The **Default** option allows to select a [contact point](/docs/grafana/latest/alerting/fundamentals/notifications/contact-points/) to handle notifications for this alert rule. The **Advanced** option routes notifications through [notification policies](/docs/grafana/latest/alerting/fundamentals/notifications/notification-policies/).

Default options

1. Select an existing [contact point](/docs/grafana/latest/alerting/fundamentals/notifications/contact-points/).
   
   All notifications for this alert rule are sent to this contact point automatically and notification policies aren’t used.
2. Optionally, configure additional notification settings like grouping or timing options.

Advanced options

With this option, all notifications for this alert rule are managed by the [notification policy tree](/docs/grafana/latest/alerting/fundamentals/notifications/notification-policies/), which routes alerts based on their labels.

You can preview which notification policy would handle notifications from this alert rule.

1. Click **Preview routing** after configuring the previous alert rule settings.
   
   Based on the alert labels and query labels, Grafana displays the notification policies that would handle the notifications.
2. Click **View route** to view policy and routing details.

You can switch between **Default** and **Advanced** options at any time.

If the [Default versus Advanced options](#default-versus-advanced-options) feature is not enabled in your Grafana instance, follow the **Advanced options** instructions.

## Configure notification message

Use [annotations](/docs/grafana/latest/alerting/fundamentals/alert-rules/annotation-label/#annotations) to add information to alert messages that can help respond to the alert.

Annotations are included by default in notification messages, and can use text or [templates](/docs/grafana/latest/alerting/alerting-rules/templates/) to display dynamic data from queries.

Grafana provides several optional annotations.

1. Optional: Add a summary.
   
   Short summary of what happened and why.
2. Optional: Add a description.
   
   Description of what the alert rule does.
3. Optional: Add a Runbook URL.
   
   Webpage where you keep your runbook for the alert
4. Optional: Add a custom annotation.
   
   Add any additional information that could help address the alert.
5. Optional: **Link dashboard and panel**.
   
   [Link the alert rule to a panel](/docs/grafana/latest/alerting/alerting-rules/link-alert-rules-to-panels/) to facilitate alert investigation.
6. Click **Save rule**.
