Prometheus rule files are held in PrometheusRule custom resources.
A PrometheusRule allows you to define one or more RuleGroups. Each RuleGroup consists of a set of Rule objects that can each represent either an alerting or a recording rule with the following fields:
- A PromQL (Prometheus query language) expression for the new alert or record
- Labels that should be attached to the alert or record that identify it (e.g. cluster name or severity)
- Annotations that encode any additional important pieces of information that need to be displayed on the notification for an alert (e.g. summary, description, message, runbook URL, etc.). This field is not required for recording rules.
Alerting rules define alert conditions based on PromQL queries. Recording rules precompute frequently needed or computationally expensive queries at defined intervals.
For more information on what fields can be specified, please look at the
For examples, refer to the Prometheus documentation on recording rules and
Connecting Routes and PrometheusRules
When you define a Rule (which is declared within a RuleGroup in a PrometheusRule resource), the contains labels that are used by Prometheus to figure out which Route should receive this Alert. For example, an Alert with the label team: front-end
will be sent to all Routes that match on that label.
Available as of v2.5.4
- Click Cluster Explorer > Monitoring and click Prometheus Rules.
- Click Create.
- Enter a Group Name.
- Click Create.
Result: Alerts can be configured to send notifications to the receiver(s).
Configuration
Rancher v2.5.4 introduced the capability to configure PrometheusRules by filling out forms in the Rancher UI.
Rule Group
Alerting rules allow you to define alert conditions based on PromQL (Prometheus Query Language) expressions and to send notifications about firing alerts to an external service.
Recording Rules
Recording rules allow you to precompute frequently needed or computationally expensive PromQL (Prometheus Query Language) expressions and save their result as a new set of time series.