Skip to main content
SRE

Prometheus

Prometheus rule evaluation slow

warning

Overview

What does this alert mean?

A rule group's evaluation takes longer than its configured interval. Alerts from this group may be delayed.

Contributing factors

  • Complex PromQL with high label cardinality
  • Prometheus under-resourced — insufficient CPU
  • TSDB under heavy concurrent write load

Affected components

  • All alerting and recording rules in the slow rule group
  • Dependent dashboards that query the recording rules

Expected action

Identify the slow rule group, pre-compute expensive sub-expressions as recording rules, or reduce cardinality.

Services

Metrics

Metric

prometheus_rule_group_last_duration_seconds

Description & unit

Duration of the last evaluation of a rule group, in seconds.

Unit: seconds

Threshold rationale

If evaluation takes longer than the group interval, subsequent evaluations queue up and alerts are delayed.

Normal behavior

Rule group evaluation should complete in well under the group interval (typically < 10% of the interval).

Screenshots

Dashboard showing rule group evaluation time exceeding interval
Dashboard showing rule group evaluation time exceeding interval
Dashboard after rule optimization
Dashboard after rule optimization

Alert Behavior

Silencing

Silence while actively optimizing the rule group.

Expected frequency

Rare — usually appears after cardinality growth or a new complex rule is added.

Severities

Severity guidance

Warning. Escalate if evaluation lag is causing known alert delays in production.

Impacted users

SRE team — delayed alerts mean slower incident detection.

Things to check to determine severity

  • Which rule group is slow? (`prometheus_rule_group_last_duration_seconds`)
  • What is the cardinality of the metrics involved?
  • Was a new rule recently added?

Verification

Prometheus query

prometheus_rule_group_last_duration_seconds > prometheus_rule_group_interval_seconds

Dashboards

  • Prometheus Self-Monitoring — Fill in: dashboard URL

Log queries

  • Prometheus slow query logs — Fill in: log query URL

Troubleshooting

Steps

  1. 1Identify slow groups: query prometheus_rule_group_last_duration_seconds and sort descending
  2. 2In Prometheus UI go to Status → Rules — look for groups with high last duration
  3. 3For each slow rule, run the PromQL manually and time it: note the cardinality of the result
  4. 4Pre-compute expensive sub-expressions as recording rules with a shorter interval
  5. 5Check Prometheus CPU usage — if saturated, scale vertically or shard rule groups

Useful commands

curl -s 'http://<prometheus>:9090/api/v1/query?query=prometheus_rule_group_last_duration_seconds' | jq '.data.result | sort_by(.value[1]) | reverse | .[:5]'

Possible Resolutions

  • A new recording rule used a high-cardinality join. Replacing the join with a pre-computed recording rule reduced evaluation time by 90%.

Dependencies

  • TSDB write throughput
  • CPU and memory available to Prometheus

Escalation

Guidance

Escalate if evaluation lag exceeds 2x the group interval for more than 10 minutes.

Slack channels

  • #observability-oncall — Fill in: channel URL

Definitions

Alert rule

Fill in: link to the alert rule in _data/rules.yml on GitHub

Tuning notes

Split large rule groups into smaller ones with focused scopes to reduce per-group evaluation time.

Related Links

Template adapted from https://runbooks.gitlab.com/template-alert-playbook/