Skip to content

Prometheus Alerting Rule Not Firing Fix

DodaTech Updated 2026-06-24 3 min read

In this tutorial, you'll learn about Prometheus Alerting Rule Not Firing Fix. We cover key concepts, practical examples, and best practices.

Your Prometheus alerting rule is green when it should be red — the alert never fires, shows PENDING but never FIRING, or fires but does not reach Alertmanager. The PromQL expression is wrong, the for duration is too long, or Alertmanager routing drops the alert.

The Problem

groups:
  - name: alerts
    rules:
      - alert: HighCPUUsage
        expr: cpu_usage_percent > 80
        for: 30m
        labels:
          severity: critical

The alert never fires because cpu_usage_percent does not exist as a metric — the expression evaluates to no data, so the alert rule is always inactive.

Step-by-Step Fix

1. Verify the PromQL expression returns data

// Test the expression in Prometheus UI
cpu_usage_percent > 80
// Should return one or more time series with values

// If empty, check the actual metric name
cpu_usage_percent  // Does this metric exist?
avg by (instance) (rate(cpu_seconds_total[5m])) * 100  // Alternative

2. Adjust the for duration

groups:
  - name: alerts
    rules:
      - alert: HighCPUUsage
        # Shorter for: duration for faster alerting
        expr: avg by (instance) (rate(cpu_seconds_total[5m])) * 100 > 80
        for: 2m  # Alert after 2 minutes above threshold
        labels:
          severity: warning
        annotations:
          summary: "CPU usage above 80% on {{ $labels.instance }}"

3. Handle absent metrics

groups:
  - name: alerts
    rules:
      - alert: InstanceDown
        # Alert when up == 0 OR when up metric is absent
        expr: up == 0 or absent(up)
        for: 1m
        labels:
          severity: critical

4. Configure Alertmanager routing

# alertmanager.yml
route:
  receiver: team-ops
  routes:
    - match:
        severity: critical
      receiver: team-ops-pager
    - match:
        severity: warning
      receiver: team-ops-slack

receivers:
  - name: team-ops-pager
    pagerduty_configs:
      - routing_key: YOUR_PAGERDUTY_KEY
  - name: team-ops-slack
    slack_configs:
      - api_url: https://hooks.slack.com/services/...
        channel: '#alerts'

5. Monitor alert rule health

// Check how many alerts are firing
count(ALERTS{alertstate="firing"}) by (severity)

// Check rule evaluation errors
prometheus_rule_evaluation_failures_total

// Check alert delivery to Alertmanager
rate(prometheus_notifications_sent_total[5m])

Expected output:

Rule evaluation: SUCCESS
Alert: HighCPUUsage → FIRING (instance=web-1, value=85.3)
Notifications sent to Alertmanager: 1

Prevention Tips

  • Test PromQL expressions in Prometheus UI before writing alert rules
  • Use for: to prevent flapping alerts (2-5m for production alerts)
  • Add meaningful annotations for alert context
  • Verify Alertmanager routing with amtool or the Alertmanager UI
  • Monitor alert rule evaluation with <a href="/devops/prometheus-grafana/">Prometheus</a>_rule_evaluation_duration_seconds

Common Mistakes with alerting rule

  1. Non-exhaustive pattern matches that compile with warnings then crash at runtime
  2. Misunderstanding that String is [Char] with poor performance for large text operations
  3. Using foldl instead of foldl' causing stack overflow on large lists

These mistakes appear frequently in real-world PROMETHEUS code. DodaTech's contributors have identified these patterns through analysis of open-source projects and production systems.

Practice Exercise

Write a pure function that safely divides two integers using Maybe, then test it with edge cases like division by zero and negative numbers.

This exercise reinforces the concepts covered in this guide. Try implementing it before checking online solutions.

FAQ

### Why does my alert stay in PENDING state?

The for: duration has not elapsed yet. The alert condition must be true continuously for the duration. Check the expression result — if the metric drops below threshold intermittently, the for: timer resets. Reduce for: or check for metric collection gaps.

What's the difference between labels and annotations?

Labels identify the alert (severity, team) and are used for routing in Alertmanager. Annotations provide context (summary, description, runbook URL) and are included in notifications. Labels cannot have template functions; annotations can use {{ $labels }} and {{ $value }}.

How do I test an alerting rule without waiting?

Use the Alert rule testing endpoint: POST /api/v1/rule/test with the rule expression and a test time series. Or set for: 0s temporarily (not recommended for production) to see the alert fire immediately.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro