2022-05-26 10:06:25 -05:00
---
2024-03-14 10:58:18 -05:00
aliases:
- ../fundamentals/data-source-alerting/ # /docs/grafana/< GRAFANA_VERSION > /alerting/fundamentals/data-source-alerting/
- ../fundamentals/alert-rules/alert-instances/ # /docs/grafana/< GRAFANA_VERSION > /alerting/fundamentals/alert-rules/alert-instances/
- ../fundamentals/alert-rules/recording-rules/ # /docs/grafana/< GRAFANA_VERSION > /alerting/fundamentals/alert-rules/recording-rules/
- ../fundamentals/alert-rules/alert-rule-types/ # /docs/grafana/< GRAFANA_VERSION > /alerting/fundamentals/alert-rules/alert-rule-types/
2023-07-18 05:29:00 -05:00
canonical: https://grafana.com/docs/grafana/latest/alerting/fundamentals/alert-rules/
2023-12-12 04:26:36 -06:00
description: Learn about alert rules
2022-05-26 10:06:25 -05:00
keywords:
- grafana
- alerting
- rules
Explicitly set all front matter labels in the source files (#71548)
* Set every page to have defaults of 'Enterprise' and 'Open source' labels
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set administration pages to have of 'Cloud', 'Enterprise', and 'Open source' labels
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set administration/enterprise-licensing pages to have 'Enterprise' labels
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set administration/organization-management pages to have 'Enterprise' and 'Open source' labels
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set administration/provisioning pages to have 'Enterprise' and 'Open source' labels
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set administration/recorded-queries pages to have labels cloud,enterprise
* Set administration/roles-and-permissions/access-control pages to have labels cloud,enterprise
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set administration/stats-and-license pages to have labels cloud,enterprise
* Set alerting pages to have labels cloud,enterprise,oss
* Set breaking-changes pages to have labels cloud,enterprise,oss
* Set dashboards pages to have labels cloud,enterprise,oss
* Set datasources pages to have labels cloud,enterprise,oss
* Set explore pages to have labels cloud,enterprise,oss
* Set fundamentals pages to have labels cloud,enterprise,oss
* Set introduction/grafana-cloud pages to have labels cloud
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Fix introduction pages products
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set panels-visualizations pages to have labels cloud,enterprise,oss
* Set release-notes pages to have labels cloud,enterprise,oss
* Set search pages to have labels cloud,enterprise,oss
* Set setup-grafana/configure-security/audit-grafana pages to have labels cloud,enterprise
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set setup-grafana/configure-security/configure-authentication pages to have labels cloud,enterprise,oss
* Set setup-grafana/configure-security/configure-authentication/enhanced-ldap pages to have labels cloud,enterprise
* Set setup-grafana/configure-security/configure-authentication/saml pages to have labels cloud,enterprise
* Set setup-grafana/configure-security/configure-database-encryption/encrypt-secrets-using-hashicorp-key-vault pages to have labels cloud,enterprise
* Set setup-grafana/configure-security/configure-request-security pages to have labels cloud,enterprise,oss
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set setup-grafana/configure-security/configure-team-sync pages to have labels cloud,enterprise
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set setup-grafana/configure-security/export-logs pages to have labels cloud,enterprise
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set troubleshooting pages to have labels cloud,enterprise,oss
* Set whatsnew pages to have labels cloud,enterprise,oss
* Apply updated labels from review
Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com>
Co-authored-by: Isabel <76437239+imatwawana@users.noreply.github.com>
---------
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com>
Co-authored-by: Isabel <76437239+imatwawana@users.noreply.github.com>
2023-07-18 03:10:12 -05:00
labels:
products:
- cloud
- enterprise
- oss
2022-05-26 10:06:25 -05:00
title: Alert rules
2024-02-28 02:10:19 -06:00
weight: 100
2022-05-26 10:06:25 -05:00
---
2022-05-24 15:04:25 -05:00
2023-04-21 06:24:43 -05:00
# Alert rules
2022-05-24 15:04:25 -05:00
2024-03-21 05:06:49 -05:00
An alert rule is a set of evaluation criteria for when an alert rule should fire. An alert rule consists of:
2022-05-24 15:04:25 -05:00
2024-03-21 05:06:49 -05:00
- Queries and expressions that select the data set to evaluate.
- A condition (the threshold) that the query must meet or exceed to trigger the alert instance.
- An interval that specifies the frequency of [alert rule evaluation][alert-rule-evaluation] and a duration indicating how long the condition must be met to trigger the alert instance.
- Other customizable options, for example, setting what should happen in the absence of data, notification messages, and more.
2022-05-24 15:04:25 -05:00
2024-03-21 05:06:49 -05:00
Grafana supports two different alert rule types: Grafana-managed alert rules and data source-managed alert rules.
2024-03-14 10:58:18 -05:00
## Grafana-managed alert rules
2024-03-21 05:06:49 -05:00
Grafana-managed alert rules are the most flexible alert rule type. They allow you to create alerts that can act on data from any of our [supported data sources ](#supported-data-sources ), and use multiple data sources in a single alert rule.
2024-03-14 10:58:18 -05:00
2024-03-21 05:06:49 -05:00
Additionally, you can also add [expressions to transform your data][expression-queries], set custom alert conditions, and include [images in alert notifications][notification-images].
2024-03-14 10:58:18 -05:00
2024-03-21 05:06:49 -05:00
{{< figure src = "/media/docs/alerting/grafana-managed-alerting-architecture.png" max-width = "750px" caption = "How Grafana-managed alerting works by default" > }}
2024-03-14 10:58:18 -05:00
1. Alert rules are created within Grafana based on one or more data sources.
1. Alert rules are evaluated by the Alert Rule Evaluation Engine from within Grafana.
2024-03-21 05:06:49 -05:00
1. Firing and resolved alert instances are delivered to the internal Grafana [Alertmanager][alert-manager] which handles notifications.
2024-03-14 10:58:18 -05:00
### Supported data sources
2024-04-15 03:56:01 -05:00
Grafana-managed alert rules can query backend data sources if Grafana Alerting is enabled by specifying `{"backend": true, "alerting": true}` in the [plugin.json ](/developers/plugin-tools/reference-plugin-json ).
2024-03-14 10:58:18 -05:00
2024-04-15 03:56:01 -05:00
Find the public data sources supporting Alerting in the [Grafana Plugins directory ](/grafana/plugins/data-source-plugins/?features=alerting ).
2024-03-14 10:58:18 -05:00
## Data source-managed alert rules
2024-03-21 05:06:49 -05:00
Data source-managed alert rules can improve query performance via [recording rules ](#recording-rules ) and ensure high-availability and fault tolerance when implementing a distributed architecture.
2024-03-14 10:58:18 -05:00
2024-03-21 05:06:49 -05:00
They are only supported for Prometheus-based or Loki data sources with the Ruler API enabled. For more information, refer to the [Loki Ruler API ](/docs/loki/<GRAFANA_VERSION>/api/#ruler ) or [Mimir Ruler API ](/docs/mimir/<GRAFANA_VERSION>/references/http-api/#ruler ).
2024-03-14 10:58:18 -05:00
2024-03-21 05:06:49 -05:00
{{< figure src = "/media/docs/alerting/mimir-managed-alerting-architecture-v2.png" max-width = "750px" caption = "Mimir-managed alerting architecture" > }}
2024-03-14 10:58:18 -05:00
1. Alert rules are created and stored within the data source itself.
2024-03-21 05:06:49 -05:00
1. Alert rules can only query Prometheus-based data. It can use either queries or [recording rules ](#recording-rules ).
1. Alert rules are evaluated by the Alert Rule Evaluation Engine.
1. Firing and resolved alert instances are delivered to the configured [Alertmanager][alert-manager] which handles notifications.
2024-03-14 10:58:18 -05:00
### Recording rules
A recording rule allows you to pre-compute frequently needed or computationally expensive expressions and save their result as a new set of time series. This is useful if you want to run alerts on aggregated data or if you have dashboards that query computationally expensive expressions repeatedly.
2024-03-21 05:06:49 -05:00
Querying this new time series is faster, especially for dashboards since they query the same expression every time the dashboards refresh. For more information, refer to [Create recording rules][create-recording-rules].
2024-03-14 10:58:18 -05:00
2024-03-21 05:06:49 -05:00
Alternatively, Grafana Enterprise and Grafana Cloud offer [recorded queries][recorded-queries] that can be executed against any data source.
2024-03-14 10:58:18 -05:00
## Comparison between alert rule types
When choosing which alert rule type to use, consider the following comparison between Grafana-managed and data source-managed alert rules.
| < div style = "width:200px" > Feature< / div > | < div style = "width:200px" > Grafana-managed alert rule< / div > | < div style = "width:200px" > Data source-managed alert rule |
| ------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- |
2024-03-21 05:06:49 -05:00
| Create alert rules< wbr / > based on data from any of our supported data sources | Yes | No. You can only create alert rules that are based on Prometheus-based data. |
2024-03-14 10:58:18 -05:00
| Mix and match data sources | Yes | No |
| Includes support for recording rules | No | Yes |
| Add expressions to transform< wbr / > your data and set alert conditions | Yes | No |
| Use images in alert notifications | Yes | No |
| Scaling | More resource intensive, depend on the database, and are likely to suffer from transient errors. They only scale vertically. | Store alert rules within the data source itself and allow for “infinite” scaling. Generate and send alert notifications from the location of your data. |
| Alert rule evaluation and delivery | Alert rule evaluation and delivery is done from within Grafana, using an external Alertmanager; or both. | Alert rule evaluation and alert delivery is distributed, meaning there is no single point of failure. |
2023-07-10 05:51:29 -05:00
{{% docs/reference %}}
2024-03-21 05:06:49 -05:00
[alert-manager]: "/docs/grafana/ -> /docs/grafana/< GRAFANA_VERSION > /alerting/fundamentals/notifications/alertmanager"
[alert-manager]: "/docs/grafana-cloud/ -> /docs/grafana-cloud/alerting-and-irm/alerting/fundamentals/notifications/alertmanager"
2024-03-14 10:58:18 -05:00
[create-recording-rules]: "/docs/grafana/ -> /docs/grafana/< GRAFANA_VERSION > /alerting/alerting-rules/create-mimir-loki-managed-recording-rule"
[create-recording-rules]: "/docs/grafana-cloud/ -> /docs/grafana-cloud/alerting-and-irm/alerting/alerting-rules/create-mimir-loki-managed-recording-rule"
[alert-rule-evaluation]: "/docs/grafana/ -> /docs/grafana/< GRAFANA_VERSION > /alerting/fundamentals/alert-rules/rule-evaluation"
[alert-rule-evaluation]: "/docs/grafana-cloud/ -> /docs/grafana-cloud/alerting-and-irm/alerting/fundamentals/alert-rules/rule-evaluation"
2023-07-10 05:51:29 -05:00
2024-03-21 05:06:49 -05:00
[expression-queries]: "/docs/grafana/ -> /docs/grafana/< GRAFANA_VERSION > /alerting/fundamentals/alert-rules/queries-conditions#expression-queries"
[expression-queries]: "/docs/grafana-cloud/ -> /docs/grafana-cloud/alerting-and-irm/alerting/fundamentals/alert-rules/queries-conditions#expression-queries"
2024-03-14 10:58:18 -05:00
[queries-and-conditions]: "/docs/grafana/ -> /docs/grafana/< GRAFANA_VERSION > /alerting/fundamentals/alert-rules/queries-conditions"
[queries-and-conditions]: "/docs/grafana-cloud/ -> /docs/grafana-cloud/alerting-and-irm/alerting/fundamentals/alert-rules/queries-conditions"
2023-07-10 05:51:29 -05:00
2024-03-21 05:06:49 -05:00
[notification-images]: "/docs/grafana/ -> /docs/grafana/< GRAFANA_VERSION > /alerting/configure-notifications/template-notifications/images-in-notifications"
[notification-images]: "/docs/grafana-cloud/ -> /docs/grafana-cloud/alerting-and-irm/alerting/configure-notifications/template-notifications/images-in-notifications"
[recorded-queries]: "/docs/ -> /docs/grafana/< GRAFANA_VERSION > /administration/recorded-queries"
2023-07-10 05:51:29 -05:00
{{% /docs/reference %}}