---
title: "No-data and error handling | Grafana Labs"
description: "What happens when a query returns nothing or fails, and the four handling options you can choose between."
---

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

## No-data and error handling

Each time an alert rule runs, it evaluates its query and decides whether to fire or stay quiet. Sometimes the rule runs but can’t decide whether to fire for two reasons:

- The query returns no data. In this case, Grafana assigns a state of **No Data**. This happens when:
  
  - No series match the query due to an incorrect metric or label filter
  - The data source stops reporting
  - The time window has no samples, often because the evaluation window or query range is too short for how often the data arrives
- The query fails to run. If this occurs, Grafana assigns a state of **Error**. This can happen with:
  
  - Evaluation timeouts
  - Repeated query failures from a data source that’s down
  - An authentication problem

Those auto-generated alerts use names like `DatasourceNoData` and `DatasourceError`, so your team may not recognize them or connect them back to your rule.

## How to handle evaluation issues

[Diagram showing the four no-data and error handling options branching from a query that returns no data](no-data-handling.svg "Diagram showing the four no-data and error handling options branching from a query that returns no data")

You can choose other options to keep your rule out of the **No Data** and **Error** states. This means no separate alert is created, and the response stays tied to your rule’s own name and routing.

| Alert state             | Use this state when                                                                         | What happens                                                                                                               |
|-------------------------|---------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------|
| Alerting                | No data means something is broken, like a heartbeat check where silence equals an outage    | Makes your own rule fire                                                                                                   |
| Normal                  | Gaps are expected and harmless, like a metric that only reports during business hours       | Keeps your rule quiet and healthy                                                                                          |
| Keep Last State         | Gaps are brief and self-healing, and you want to avoid the rule flapping on a missed scrape | Holds whatever state your rule had before the gap                                                                          |
| No Data/Error (default) | You want a separate signal that the data pipeline broke, routed apart from your rule        | Leaves your rule quiet and raises a separate alert named `DatasourceNoData` (for No Data) or `DatasourceError` (for Error) |

## Common mistake

The **Configure no data and error handling** options in Grafana are powerful, but they require close attention. Don’t set the **Alert state if no data or all values are null** option to **Normal** unless you’re certain that data gaps are safe. Otherwise your rule stays silent during a real outage, and you hear nothing when the underlying data source stops reporting.
