mirror of
https://github.com/grafana/grafana.git
synced 2025-07-28 02:32:07 +08:00

* Clarify DS managed rules support only the creation of Mimir and Loki rules * additional copy changes * Extend `Manage alerts via Alerting UI` description * fix capital letter * further details for `Manage alerts via Alerting UI`
158 lines
8.8 KiB
Markdown
158 lines
8.8 KiB
Markdown
---
|
|
aliases:
|
|
- ../unified-alerting/alerting-rules/create-mimir-loki-managed-rule/ # /docs/grafana/<GRAFANA_VERSION>/alerting/unified-alerting/alerting-rules/create-mimir-loki-managed-rule/
|
|
- ../unified-alerting/alerting-rules/edit-cortex-loki-namespace-group/ # /docs/grafana/<GRAFANA_VERSION>/alerting/unified-alerting/alerting-rules/edit-cortex-loki-namespace-group/
|
|
- ../unified-alerting/alerting-rules/edit-mimir-loki-namespace-group/ # /docs/grafana/<GRAFANA_VERSION>/alerting/unified-alerting/alerting-rules/edit-mimir-loki-namespace-group/
|
|
- ../alerting-rules/create-mimir-loki-managed-rule/ # /docs/grafana/<GRAFANA_VERSION>/alerting/alerting-rules/create-mimir-loki-managed-rule/
|
|
canonical: https://grafana.com/docs/grafana/latest/alerting/alerting-rules/create-data-source-managed-rule/
|
|
description: Configure data source-managed alert rules alert for an external Grafana Mimir or Loki instance
|
|
keywords:
|
|
- grafana
|
|
- alerting
|
|
- guide
|
|
- rules
|
|
- create
|
|
labels:
|
|
products:
|
|
- cloud
|
|
- enterprise
|
|
- oss
|
|
title: Configure data source-managed alert rules
|
|
weight: 200
|
|
refs:
|
|
shared-configure-prometheus-data-source-alerting:
|
|
- pattern: /docs/grafana/
|
|
destination: /docs/grafana/<GRAFANA_VERSION>/datasources/prometheus/configure-prometheus-data-source/#alerting
|
|
- pattern: /docs/grafana-cloud/
|
|
destination: /docs/grafana-cloud/connect-externally-hosted/data-sources/prometheus/configure-prometheus-data-source/#alerting
|
|
configure-grafana-managed-rules:
|
|
- pattern: /docs/grafana/
|
|
destination: /docs/grafana/<GRAFANA_VERSION>/alerting/alerting-rules/create-grafana-managed-rule/
|
|
- pattern: /docs/grafana-cloud/
|
|
destination: /docs/grafana-cloud/alerting-and-irm/alerting/alerting-rules/create-grafana-managed-rule/notification-policies/
|
|
notification-policies:
|
|
- pattern: /docs/grafana/
|
|
destination: /docs/grafana/<GRAFANA_VERSION>/alerting/fundamentals/notifications/notification-policies/
|
|
- pattern: /docs/grafana-cloud/
|
|
destination: /docs/grafana-cloud/alerting-and-irm/alerting/fundamentals/notifications/notification-policies/
|
|
pending-period:
|
|
- pattern: /docs/grafana/
|
|
destination: /docs/grafana/<GRAFANA_VERSION>/alerting/fundamentals/alert-rule-evaluation/#pending-period
|
|
- pattern: /docs/grafana-cloud/
|
|
destination: /docs/grafana-cloud/alerting-and-irm/alerting/fundamentals/alert-rule-evaluation/#pending-period
|
|
alert-rules:
|
|
- pattern: /docs/grafana/
|
|
destination: /docs/grafana/<GRAFANA_VERSION>/alerting/fundamentals/alert-rules/
|
|
- pattern: /docs/grafana-cloud/
|
|
destination: /docs/grafana-cloud/alerting-and-irm/alerting/fundamentals/alert-rules/
|
|
alert-rule-labels:
|
|
- pattern: /docs/grafana/
|
|
destination: /docs/grafana/<GRAFANA_VERSION>/alerting/fundamentals/alert-rules/annotation-label/#labels
|
|
- pattern: /docs/grafana-cloud/
|
|
destination: /docs/grafana-cloud/alerting-and-irm/alerting/fundamentals/alert-rules/annotation-label/#labels
|
|
alert-rule-evaluation:
|
|
- pattern: /docs/grafana/
|
|
destination: /docs/grafana/<GRAFANA_VERSION>/alerting/fundamentals/alert-rule-evaluation/
|
|
- pattern: /docs/grafana-cloud/
|
|
destination: /docs/grafana-cloud/alerting-and-irm/alerting/fundamentals/alert-rule-evaluation/
|
|
shared-provision-alerting-resources:
|
|
- pattern: /docs/grafana/
|
|
destination: /docs/grafana/<GRAFANA_VERSION>/alerting/set-up/provision-alerting-resources/
|
|
- pattern: /docs/grafana-cloud/
|
|
destination: /docs/grafana-cloud/alerting-and-irm/alerting/set-up/provision-alerting-resources/
|
|
shared-alert-rule-template:
|
|
- pattern: /docs/grafana/
|
|
destination: /docs/grafana/<GRAFANA_VERSION>/alerting/alerting-rules/templates/
|
|
- pattern: /docs/grafana-cloud/
|
|
destination: /docs/grafana-cloud/alerting-and-irm/alerting/alerting-rules/templates/
|
|
shared-annotations:
|
|
- pattern: /docs/grafana/
|
|
destination: /docs/grafana/<GRAFANA_VERSION>/alerting/fundamentals/alert-rules/annotation-label/#annotations
|
|
- pattern: /docs/grafana-cloud/
|
|
destination: /docs/grafana-cloud/alerting-and-irm/alerting/fundamentals/alert-rules/annotation-label/#annotations
|
|
shared-link-alert-rules-to-panels:
|
|
- pattern: /docs/grafana/
|
|
destination: /docs/grafana/<GRAFANA_VERSION>/alerting/alerting-rules/link-alert-rules-to-panels/
|
|
- pattern: /docs/grafana-cloud/
|
|
destination: /docs/grafana-cloud/alerting-and-irm/alerting/alerting-rules/link-alert-rules-to-panels/
|
|
---
|
|
|
|
# Configure data source-managed alert rules
|
|
|
|
Data source-managed alert rules can only be created using Grafana Mimir or Grafana Loki data sources.
|
|
|
|
The rules are stored within the data source. In a distributed architecture, they can scale horizontally to provide high-availability. For more details, refer to [alert rule types](ref:alert-rules).
|
|
|
|
We recommend using [Grafana-managed alert rules](ref:configure-grafana-managed-rules) whenever possible and opting for data source-managed alert rules when scaling your alerting setup is necessary.
|
|
|
|
{{< docs/shared lookup="alerts/note-prometheus-ds-rules.md" source="grafana" version="<GRAFANA_VERSION>" >}}
|
|
|
|
To create or edit data source-managed alert rules, follow these instructions.
|
|
|
|
## Before you begin
|
|
|
|
Verify that you have write permission to the Mimir or Loki data source. Otherwise, you cannot create or update data source-managed alert rules.
|
|
|
|
### Enable the Ruler API
|
|
|
|
For more information, refer to the [Mimir Ruler API](/docs/mimir/latest/references/http-api/#ruler) or [Loki Ruler API](/docs/loki/latest/api/#ruler).
|
|
|
|
- **Mimir** - use the `/prometheus` prefix. The Prometheus data source supports both Grafana Mimir and Prometheus, and Grafana expects that both the [Query API](/docs/mimir/latest/operators-guide/reference-http-api/#querier--query-frontend) and [Ruler API](/docs/mimir/latest/operators-guide/reference-http-api/#ruler) are under the same URL. You cannot provide a separate URL for the Ruler API.
|
|
|
|
- **Loki** - The `local` rule storage type, default for the Loki data source, supports only viewing of rules. To edit rules, configure one of the other rule storage types.
|
|
|
|
### Permissions
|
|
|
|
Alert rules for Mimir or Loki instances can be edited or deleted by users with **Editor** or **Admin** roles.
|
|
|
|
If you do not want to manage alert rules for a particular data source, go to its settings and clear the **Manage alerts via Alerting UI** checkbox.
|
|
|
|
{{< docs/shared lookup="alerts/configure-provisioning-before-begin.md" source="grafana" version="<GRAFANA_VERSION>" >}}
|
|
|
|
{{< docs/shared lookup="alerts/configure-alert-rule-name.md" source="grafana" version="<GRAFANA_VERSION>" >}}
|
|
|
|
## 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.
|
|
|
|
{{% admonition type="note" %}}
|
|
By default, new alert rules are Grafana-managed. To switch to **Data source-managed**, follow these instructions.
|
|
{{% /admonition %}}
|
|
|
|
1. Select a Prometheus-based data source from the drop-down list.
|
|
|
|
You can also click **Open advanced data source picker** to find more options.
|
|
|
|
1. Enter a PromQL or LogQL query, including the alert condition.
|
|
1. In the **Rule type** option, select **Data source-managed**.
|
|
1. Click **Preview alerts**.
|
|
|
|
## Set alert evaluation behavior
|
|
|
|
Use [alert rule evaluation](ref:alert-rule-evaluation) to determine how frequently an alert rule should be evaluated and how quickly it should change its state.
|
|
|
|
1. Select a namespace or click **+ New namespace**.
|
|
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 sequentially over the same time interval. You can reorder them from the **Alert rules** page.
|
|
|
|
1. Enter a pending period.
|
|
|
|
The [pending period](ref:pending-period) is the period in which an alert rule can be in breach of the condition until it fires.
|
|
|
|
Once 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.
|
|
|
|
## Configure labels and notifications
|
|
|
|
Add [labels](ref:alert-rule-labels) to your alert rules to set which [notification policy](ref:notification-policies) should handle your firing alert instances.
|
|
|
|
All alert rules and instances, irrespective of their labels, match the default notification policy. If there are no nested policies, or no nested policies match the labels in the alert rule or alert instance, then the default notification policy is the matching policy.
|
|
|
|
1. Add labels if you want to change the way your notifications are routed.
|
|
|
|
Add custom labels by selecting existing key-value pairs from the drop down, or add new labels by entering the new key or value.
|
|
|
|
{{< docs/shared lookup="alerts/configure-notification-message.md" source="grafana" version="<GRAFANA_VERSION>" >}}
|