Skip to content

Commit fc917e9

Browse files
Merge pull request #246805 from yairgil/docs-editor/prometheus-rule-groups-1690814505
Update prometheus-rule-groups.md
2 parents 90840d0 + da4e2d1 commit fc917e9

File tree

1 file changed

+50
-16
lines changed

1 file changed

+50
-16
lines changed

articles/azure-monitor/essentials/prometheus-rule-groups.md

Lines changed: 50 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ ms.date: 09/28/2022
1111
# Azure Monitor managed service for Prometheus rule groups
1212
Rules in Prometheus act on data as it's collected. They're configured as part of a Prometheus rule group, which is stored in [Azure Monitor workspace](azure-monitor-workspace-overview.md). Rules are run sequentially in the order they're defined in the group.
1313

14-
1514
## Rule types
1615
There are two types of Prometheus rules as described in the following table.
1716

@@ -21,18 +20,51 @@ There are two types of Prometheus rules as described in the following table.
2120
| Recording |[Recording rules](https://aka.ms/azureprometheus-promio-recrules) allow you to precompute frequently needed or computationally extensive expressions and store their result as a new set of time series. Time series created by recording rules are ingested back to your Azure Monitor workspace as new Prometheus metrics. |
2221

2322
## Create Prometheus rules
24-
Azure Managed Prometheus rule groups, recording rules and alert rules can be created and configured using The Azure resource type **Microsoft.AlertsManagement/prometheusRuleGroups**, where the alert rules and recording rules are defined as part of the rule group properties.Prometheus rule groups are defined with a scope of a specific [Azure Monitor workspace](azure-monitor-workspace-overview.md). Prometheus rule groups can be created using Azure Resource Manager (ARM) templates, API, Azure CLI, or PowerShell.
23+
Azure Managed Prometheus rule groups, recording rules and alert rules can be created and configured using The Azure resource type **Microsoft.AlertsManagement/prometheusRuleGroups**, where the alert rules and recording rules are defined as part of the rule group properties. Prometheus rule groups are defined with a scope of a specific [Azure Monitor workspace](azure-monitor-workspace-overview.md). Prometheus rule groups can be created using Azure Resource Manager (ARM) templates, API, Azure CLI, or PowerShell.
24+
25+
Azure managed Prometheus rule groups follow the structure and terminology of the open source Prometheus rule groups. Rule names, expression, 'for' clause, labels, annotations are all supported in the Azure version. The following key differences between OSS rule groups and Azure managed Prometheus should be noted:
26+
* Azure managed Prometheus rule groups are managed as Azure resources, and include necessary information for resource management, such as the subscription and resource group where the Azure rule group should reside.
27+
* Azure managed Prometheus alert rules include dedicated properties that allow alerts to be processed like other Azure Monitor alerts. For example, alert severity, action group association, and alert auto resolve configuration are supported as part of Azure managed Prometheus alert rules.
2528

2629
> [!NOTE]
2730
> For your AKS or ARC Kubernetes clusters, you can use some of the recommended alerts rules. See pre-defined alert rules [here](../containers/container-insights-metric-alerts.md#enable-prometheus-alert-rules).
2831
2932
### Limiting rules to a specific cluster
3033

31-
You can optionally limit the rules in a rule group to query data originating from a specific cluster, using the rule group `clusterName` property.
32-
You should limit rules to a single cluster if your Azure Monitor workspace contains a large amount of data from multiple clusters. In such a case, there's a concern that running a single set of rules on all the data may cause performance or throttling issues. By using the `clusterName` property, you can create multiple rule groups, each configured with the same rules, and therefore limit each group to cover a different cluster.
34+
You can optionally limit the rules in a rule group to query data originating from a single specific cluster, by adding a cluster scope to your rule group, and/or by using the rule group `clusterName` property.
35+
You should limit rules to a single cluster if your Azure Monitor workspace contains a large amount of data from multiple clusters. In such a case, there's a concern that running a single set of rules on all the data may cause performance or throttling issues. By using the cluster scope, you can create multiple rule groups, each configured with the same rules, with each group covering a different cluster.
36+
37+
To limit your rule group to a cluster scope, you should add the Azure Resource ID of your cluster to the rule group **scopes[]** list. **The scopes list must still include the Azure Monitor workspace resource ID**. The following cluster resource types are supported as a cluster scope:
38+
* Azure Kubernetes Service clusters (AKS) (Microsoft.ContainerService/managedClusters)
39+
* Azure Arc-enabled Kubernetes clusters (Microsoft.kubernetes/connectedClusters)
40+
* Azure connected appliances (Microsoft.ResourceConnector/appliances)
41+
42+
In addition to the cluster ID, you can configure the **clusterName** property of your rule group. The 'clusterName' property must match the `cluster` label that is added to your metrics when scraped from a specific cluster. By default, this label is set to the last part (resource name) of your cluster ID. If you've changed this label using the ['cluster_alias'](../essentials/prometheus-metrics-scrape-configuration.md#cluster-alias) setting in your cluster scraping configmap, you must include the updated value in the rule group 'clusterName' property. If your scraping uses the default 'cluster' label value, the 'clusterName' property is optional.
43+
44+
Here's an example of how a rule group is configured to limit query to a specific cluster:
3345

34-
- The `clusterName` value must be identical to the `cluster` label that is added to the metrics from a specific cluster during data collection.
35-
- If `clusterName` isn't specified for a specific rule group, the rules in the group query all the data in the workspace from all clusters.
46+
``` json
47+
{
48+
"name": "sampleRuleGroup",
49+
"type": "Microsoft.AlertsManagement/prometheusRuleGroups",
50+
"apiVersion": "2023-03-01",
51+
"location": "northcentralus",
52+
"properties": {
53+
"description": "Sample Prometheus Rule Group limited to a specific cluster",
54+
"scopes": [
55+
"/subscriptions/<subscription-id>/resourcegroups/<resource-group-name>/providers/microsoft.monitor/accounts/<azure-monitor-workspace-name>",
56+
"/subscriptions/<subscription-id>/resourcegroups/<resource-group-name>/providers/microsoft.containerservice/managedclusters/<myClusterName>"
57+
],
58+
"clusterName": "<myCLusterName>",
59+
"rules": [
60+
{
61+
...
62+
}
63+
]
64+
}
65+
}
66+
```
67+
If both cluster ID scope and `clusterName` aren't specified for a rule group, the rules in the group query data from all the clusters in the workspace from all clusters.
3668

3769
### Creating Prometheus rule group using Resource Manager template
3870

@@ -44,7 +76,7 @@ The basic steps are as follows:
4476
2. Deploy the template using any deployment method, such as [Azure portal](../../azure-resource-manager/templates/deploy-portal.md), [Azure CLI](../../azure-resource-manager/templates/deploy-cli.md), [Azure PowerShell](../../azure-resource-manager/templates/deploy-powershell.md), or [Rest API](../../azure-resource-manager/templates/deploy-rest.md).
4577

4678
### Template example for a Prometheus rule group
47-
Following is a sample template that creates a Prometheus rule group, including one recording rule and one alert rule. This template creates a resource of type `Microsoft.AlertsManagement/prometheusRuleGroups`. The rules are executed in the order they appear within a group.
79+
Following is a sample template that creates a Prometheus rule group, including one recording rule and one alert rule. This template creates a resource of type `Microsoft.AlertsManagement/prometheusRuleGroups`. The scope of this group is limited to a single AKS cluster. The rules are executed in the order they appear within a group.
4880

4981
``` json
5082
{
@@ -61,7 +93,8 @@ Following is a sample template that creates a Prometheus rule group, including o
6193
"properties": {
6294
"description": "Sample Prometheus Rule Group",
6395
"scopes": [
64-
"/subscriptions/<subscription-id>/resourcegroups/<resource-group-name>/providers/microsoft.monitor/accounts/<azure-monitor-workspace-name>"
96+
"/subscriptions/<subscription-id>/resourcegroups/<resource-group-name>/providers/microsoft.monitor/accounts/<azure-monitor-workspace-name>",
97+
"/subscriptions/<subscription-id>/resourcegroups/<resource-group-name>/providers/microsoft.containerservice/managedclusters/<myClusterName>"
6598
],
6699
"enabled": true,
67100
"clusterName": "<myCLusterName>",
@@ -95,7 +128,7 @@ Following is a sample template that creates a Prometheus rule group, including o
95128
},
96129
"actions": [
97130
{
98-
"actionGroupId": "/subscriptions/<subscription-id>/resourcegroups/<resource-group-name>/providers/microsoft.insights/actiongroups/<action-group-name>"
131+
"actionGroupID": "/subscriptions/<subscription-id>/resourcegroups/<resource-group-name>/providers/microsoft.insights/actiongroups/<action-group-name>"
99132
}
100133
]
101134
}
@@ -116,11 +149,11 @@ The rule group contains the following properties.
116149
| `name` | True | string | Prometheus rule group name |
117150
| `type` | True | string | `Microsoft.AlertsManagement/prometheusRuleGroups` |
118151
| `apiVersion` | True | string | `2023-03-01` |
119-
| `location` | True | string | Resource location from regions supported in the preview |
120-
| `properties.description` | False | string | Rule group description |
121-
| `properties.scopes` | True | string[] | Target Azure Monitor workspace. Only one scope currently supported |
152+
| `location` | True | string | Resource location from regions supported in the preview. |
153+
| `properties.description` | False | string | Rule group description. |
154+
| `properties.scopes` | True | string[] | Must include the target Azure Monitor workspace ID. Can optionally include one more cluster ID, as well. |
122155
| `properties.enabled` | False | boolean | Enable/disable group. Default is true. |
123-
| `properties.clusterName` | False | string | Apply rule to data from a specific cluster. Default is apply to all data in workspace. |
156+
| `properties.clusterName` | False | string | Must match the `cluster` label that is added to metrics scraped from your target cluster. By default, set to the last part (resource name) of cluster ID that appears in scopes[]. |
124157
| `properties.interval` | False | string | Group evaluation interval. Default = PT1M |
125158

126159
### Recording rules
@@ -140,7 +173,7 @@ The `rules` section contains the following properties for alerting rules.
140173
|:---|:---|:---|:---|:---|
141174
| `alert` | False | string | Alert rule name |
142175
| `expression` | True | string | PromQL expression to evaluate. |
143-
| `for` | False | string | Alert firing timeout. Values - 'PT1M', 'PT5M' etc. |
176+
| `for` | False | string | Alert firing timeout. Values - PT1M, PT5M etc. |
144177
| `labels` | False | object | labels key-value pairs | Prometheus alert rule labels. These labels are added to alerts fired by this rule. |
145178
| `rules.annotations` | False | object | Annotations key-value pairs to add to the alert. |
146179
| `enabled` | False | boolean | Enable/disable group. Default is true. |
@@ -153,10 +186,10 @@ The `rules` section contains the following properties for alerting rules.
153186

154187
If you have a [Prometheus rules configuration file](https://prometheus.io/docs/prometheus/latest/configuration/recording_rules/#configuring-rules) (in YAML format), you can now convert it to an Azure Prometheus rule group ARM template, using the [az-prom-rules-converter utility](https://github.com/Azure/prometheus-collector/tree/main/tools/az-prom-rules-converter#az-prom-rules-converter). The rules file can contain definition of one or more rule groups.
155188

156-
In addition to the rules file, you can provide the utility with additional properties that are needed to create the Azure Prometheus rule groups, including: subscription, resource group, location, target Azure Monitor workspace, target cluster name, and action groups (used for alert rules). The utility creates a template file that can be deployed directly or within a deployment pipe providing some of these properties as parameters. Note that properties provided to the utility are used for all the rule groups in the template, e.g., all rule groups in the file will be created in the same subscription/resource group/location, using the same Azure Monitor workspace, etc. If an action group is provided as a parameter to the utility, the same action group will be used in all the alert rules in the template. If you want to change this default configuration (e.g., use different action groups in different rules) you can edit the resulting template according to your needs, before deploying it.
189+
In addition to the rules file, you must provide the utility with other properties that are needed to create the Azure Prometheus rule groups, including: subscription, resource group, location, target Azure Monitor workspace, target cluster ID and name, and action groups (used for alert rules). The utility creates a template file that can be deployed directly or within a deployment pipe providing some of these properties as parameters. Properties that you provide to the utility are used for all the rule groups in the template. For example, all rule groups in the file are created in the same subscription, resource group and location, and using the same Azure Monitor workspace. If an action group is provided as a parameter to the utility, the same action group is used in all the alert rules in the template. If you want to change this default configuration (for example, use different action groups in different rules) you can edit the resulting template according to your needs, before deploying it.
157190

158191
> [!NOTE]
159-
> !The az-prom-convert-utility is provided as a courtesy tool. We recommend that you review the resulting template and verify it matches your intended configuration.
192+
> The az-prom-convert-utility is provided as a courtesy tool. We recommend that you review the resulting template and verify it matches your intended configuration.
160193
161194
### Creating Prometheus rule group using Azure CLI
162195

@@ -202,6 +235,7 @@ To enable or disable a rule, select the rule in the Azure portal. Select either
202235
> After you disable or re-enable a rule or a rule group, it may take few minutes for the rule group list to reflect the updated status of the rule or the group.
203236
204237

238+
205239
## Next steps
206240

207241
- [Learn more about the Azure alerts](../alerts/alerts-types.md).

0 commit comments

Comments
 (0)