If you want to create the same alert rule for Prometheus instances in different regions, you can use the alert rule template feature of Prometheus Service. This topic describes how to create and manage alert rule templates.
Background information
If you want to create alert rules for Prometheus instances in different regions, you can create an alert rule for each Prometheus instance. This method results in a high workload and low management efficiency. To address this issue, Alibaba Cloud Prometheus Service provides the alert rule template feature. You can create an alert rule template and apply the template to multiple Prometheus instances. You can manage the alert rules of these Prometheus instances in a unified and cost-efficient manner.
Operations related to the alert rule template feature
- Create an alert rule template
- Modify an alert rule template
- Apply an alert rule template
- Prometheus instance selection mode
- Tag controller mode
- Delete an alert rule template
- View the alert rules that are created from a template
- Enable multiple alert rules at a time
- Disable multiple alert rules at a time
- Delete multiple alert rules at a time
- Apply multiple templates at a time
- Delete multiple templates at a time
Create an alert rule template
Apply an alert rule template
After you create an alert rule template, you can apply the template to specific Prometheus instances to create alert rules or update existing alert rules.
You can apply an alert template in one of the following modes:
Prometheus instance selection mode
Tag controller mode
You can add tags to a cluster in the Container Service for Kubernetes (ACK) console. Then, you can go to the ARMS console and filter clusters by tag on the Tag Controller Mode tab. You can configure tags for each template. After the configuration is complete, alert rules are created for the Prometheus instances that monitor the clusters that are matched.
The system dynamically updates alert rules based on tags:
- When a template is modified, the alert rules that are used to monitor the clusters that match the tags are updated based on the new template.
- If you modify an alert rule that is created in tag controller mode and retain the mapping between the alert rule and the alert rule template, the modifications are overwritten by the new template.
- If the tags of an ACK cluster are changed, the tags of the Prometheus instance that monitors the cluster are also changed. The system deletes or creates alert rules based on the new tags.
- Log on to the ACK console and add tags to a cluster.
- On the Prometheus Alert Rule Template page of the ARMS console, find the alert rule template that you want to apply and click Apply Template in the Actions column.
- In the Apply Template dialog box, click the Tag Controller Mode tab. Then, specify tags and expressions.
Delete a template
If you no longer need to use an alert rule template, you can delete the template. When you delete a template, you can specify whether to retain the alert rules that are created from the template.
View the alert rules that are created from a template
You can view and manage the alert rules that are created from a template.
Precautions
- If you select Retain the mapping between this alert rule and the alert rule template, your modifications may be overwritten when you apply the template to the Prometheus instance corresponding to the alert rule and select Update Created Alert Rules.
- If you select Remove the mapping between this alert rule and the alert rule template, the alert rule is considered as a separate rule. We recommend that you rename the alert rule. Otherwise, if you apply the alert rule template to the Prometheus instance again, a new alert rule fails to be created due to name conflicts.