Docs: updates alerting rules docs (#72190)

* Docs: updates alerting rules docs

* Docs: adds queries and conditions topic
This commit is contained in:
brendamuir 2023-07-24 15:57:41 +02:00 committed by GitHub
parent f917fbfe42
commit 43fb14ef8c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 56 additions and 32 deletions

View File

@ -3,7 +3,7 @@ aliases:
- ../unified-alerting/alerting-rules/create-cortex-loki-managed-recording-rule/
- ../unified-alerting/alerting-rules/create-mimir-loki-managed-recording-rule/
canonical: https://grafana.com/docs/grafana/latest/alerting/alerting-rules/create-mimir-loki-managed-recording-rule/
description: Create Grafana Mimir or Loki managed recording rule
description: Create recording rules
keywords:
- grafana
- alerting
@ -16,11 +16,11 @@ labels:
- cloud
- enterprise
- oss
title: Create Grafana Mimir or Loki managed recording rules
title: Create recording rules
weight: 400
---
# Create Grafana Mimir or Loki managed recording rules
# Create recording rules
You can create and manage recording rules for an external Grafana Mimir or Loki instance. Recording rules calculate frequently needed expressions or computationally expensive expressions in advance and save the result as a new set of time series. Querying this new time series is faster, especially for dashboards since they query the same expression every time the dashboards refresh.
@ -46,28 +46,27 @@ This setting has precedence over each individual rule frequency. If a rule frequ
If you do not want to manage alerting rules for a particular Loki or Prometheus data source, go to its settings and clear the **Manage alerts via Alerting UI** checkbox.
{{% /admonition %}}
## Add a Grafana Mimir or Loki managed recording rule
## Add recording rules
To create a Grafana Mimir or Loki managed recording rule
To create recording rules, follow these steps.
1. In the left-side menu, click **Alerts & IRM** and then **Alerting**.
1. Click **Alerts & IRM** and then **Alerting**.
1. Click **Alert rules**.
1. Click **+ Create alert rule**. The new alerting rule page opens where the **Grafana managed alert** option is selected by default.
1. Click the **More** dropdown and then **New recording rule**.
1. In Step 1, add the rule name. The recording name must be a Prometheus metric name and contain no whitespace.
- In **Rule name**, add a descriptive name.
1. In Step 2, select **Mimir or Loki recording rule** option.
1. In Step 2, select a data source.
- Select your Loki or Prometheus data source.
- Enter a PromQL or LogQL query.
1. In Step 3, add alert evaluation behavior.
- Enter a valid **For** duration. The expression has to be true for this long for the alert to be fired.
1. In Step 4, add additional metadata associated with the rule.
- Enter a query.
1. In Step 3, add a namespace and a group.
- From the **Namespace** dropdown, select an existing rule namespace or add a new one. Namespaces can contain one or more rule groups and only have an organizational purpose. For more information, see [Grafana Mimir or Loki rule groups and namespaces][edit-mimir-loki-namespace-group].
- From the **Group** dropdown, select an existing group within the selected namespace or add a new one. Newly created rules are appended to the end of the group. Rules within a group are run sequentially at a regular interval, with the same evaluation time.
- Add a description and summary to customize alert messages. Use the guidelines in [Annotations and labels for alerting][annotation-label].
- Add Runbook URL, panel, dashboard, and alert IDs.
1. In Step 5, add custom labels.
1. In Step 4, add custom labels.
- Add custom labels selecting existing key-value pairs from the drop down, or add new labels by entering the new key or value .
1. Click **Save** to save the rule or **Save and exit** to save the rule and go back to the Alerting page.
1. Click **Save rule** to save the rule or **Save rule and exit** to save the rule and go back to the Alerting page.
{{% docs/reference %}}
[annotation-label]: "/docs/grafana/ -> /docs/grafana/<GRAFANA VERSION>/alerting/fundamentals/annotation-label"

View File

@ -11,7 +11,7 @@ labels:
- enterprise
- oss
title: Alert rules
weight: 105
weight: 106
---
# Alert rules

View File

@ -11,7 +11,7 @@ labels:
- enterprise
- oss
title: Alert instances
weight: 104
weight: 105
---
# Alert instances

View File

@ -16,7 +16,7 @@ weight: 102
# Alert rule types
Grafana supports several different alert rule types. Learn more about each of the alert rule types, how they work, and decide which one is best for your use case.
Grafana supports two different alert rule types. Learn more about each of the alert rule types, how they work, and decide which one is best for your use case.
## Grafana-managed alert rules
@ -39,15 +39,15 @@ The following diagram shows how Grafana-managed alerting works.
You can also configure alerts to be delivered using an external Alertmanager; or use both internal and external alertmanagers.
For more information, see Add an external Alertmanager.
## Grafana Mimir or Loki-managed alert rules
## Data source-managed alert rules
To create Grafana Mimir or Grafana Loki-managed alert rules, you must have a compatible Prometheus or Loki data source.
To create data source-managed alert rules, you must have a compatible Prometheus or Loki data source.
You can check if your data source supports rule creation via Grafana by testing the data source and observing if the Ruler API is supported.
For more information on the Ruler API, refer to [Ruler API](/docs/loki/latest/api/#ruler).
The following diagram shows how Grafana Mimir or Grafana Loki-managed alerting works.
The following diagram shows how data source-managed alerting works.
{{< figure src="/media/docs/alerting/loki-mimir-rule.png" max-width="750px" caption="Grafana Mimir/Loki-managed alerting" >}}
@ -55,16 +55,6 @@ The following diagram shows how Grafana Mimir or Grafana Loki-managed alerting w
1. Alert rules can only be created based on Prometheus data.
1. Alert rule evaluation and delivery is distributed across multiple nodes for high availability and fault tolerance.
## Recording rules
Recording rules are only available for compatible Prometheus or Loki data sources.
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.
Grafana Enterprise offers an alternative to recorded rules in the form of recorded queries that can be executed against any data source.
For more information on recording rules in Prometheus, refer to [recording rules](https://prometheus.io/docs/prometheus/latest/configuration/recording_rules/).
## Choose an alert rule type
When choosing which alert rule type to use, consider the following comparison between Grafana-managed alert rules and Grafana Mimir or Loki alert rules.

View File

@ -12,7 +12,7 @@ labels:
- enterprise
- oss
title: Queries and conditions
weight: 103
weight: 104
---
# Queries and conditions

View File

@ -0,0 +1,35 @@
---
canonical: https://grafana.com/docs/grafana/latest/alerting/fundamentals/alert-rules/recording-rules/
description: Learn about recording rules
keywords:
- grafana
- alerting
- recording rules
labels:
products:
- cloud
- enterprise
- oss
title: Recording rules
weight: 103
---
# Recording rules
_Recording rules are only available for compatible Prometheus or Loki data sources._
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.
Querying this new time series is faster, especially for dashboards since they query the same expression every time the dashboards refresh.
Grafana Enterprise offers an alternative to recorded rules in the form of recorded queries that can be executed against any data source.
For more information on recording rules in Prometheus, refer to [recording rules](https://prometheus.io/docs/prometheus/latest/configuration/recording_rules/).
**Note:**
Recording rules are run as instant rules, which means that they run every 10s. To overwrite this configuration, update the min_interval in your custom configuration file.
[min_interval][configure-grafana] sets the minimum interval to enforce between rule evaluations. The default value is 10s which equals the scheduler interval. Rules will be adjusted if they are less than this value or if they are not multiple of the scheduler interval (10s). Higher values can help with resource management as fewer evaluations are scheduled over time.
This setting has precedence over each individual rule frequency. If a rule frequency is lower than this value, then this value is enforced.