Prometheus Alertmanager Inhibition Rules Not Working Fix
In this tutorial, you'll learn about Prometheus Alertmanager Inhibition Rules Not Working Fix. We cover key concepts, practical examples, and best practices.
Your Alertmanager inhibition rules do not suppress lower-severity alerts — DatacenterDown fires but HostDown and ServiceDown alerts still notify. Inhibition rules must match labels between the source and target alerts exactly.
The Problem
inhibit_rules:
- source_match:
alertname: DatacenterDown
target_match:
alertname: HostDown
equal: ['datacenter']
The HostDown alert does not have a datacenter label, or the value does not match the DatacenterDown alert's datacenter label. The inhibition rule requires the equal labels to have matching values.
Step-by-Step Fix
1. Ensure target alerts have matching labels
# Source alert
alert: DatacenterDown
expr: ...
labels:
severity: critical
datacenter: us-east-1
# Target alert (must have the same datacenter label)
alert: HostDown
expr: ...
labels:
severity: warning
datacenter: us-east-1 # Must match source
2. Configure inhibition rules correctly
inhibit_rules:
# High-severity inhibition
- source_match:
severity: critical
target_match:
severity: warning
equal: ['datacenter']
# Specific inhibition
- source_match:
alertname: DatacenterDown
target_match:
alertname: HostDown
equal: ['datacenter']
# Global inhibition (no equal labels)
- source_match:
alertname: Watchdog
target_match:
severity: critical
# No equal — inhibits ALL critical alerts when Watchdog fires
# (Watchdog fires indicate Alertmanager is working)
3. Use regex matching for target alerts
inhibit_rules:
# Inhibit all alerts with severity=warning or severity=info
# when any alert with severity=critical fires
- source_match:
severity: critical
target_match_re:
severity: 'warning|info'
equal: ['datacenter', 'service']
4. Test inhibition rules
# Use amtool to test inhibition
amtool config routes --alertmanager.url=http://localhost:9093
# Simulate alerts
amtool alert add \
--alertmanager.url=http://localhost:9093 \
DatacenterDown severity=critical datacenter=us-east-1
# Check inhibited alerts
amtool alert query \
--alertmanager.url=http://localhost:9093 \
--inhibited
5. Debug with Alertmanager UI
# Open Alertmanager UI
# http://localhost:9093
# Check Silences & Inhibitions section
# See which alerts are inhibited and by which source
Expected output:
Active alerts:
DatacenterDown (critical) — FIRING
HostDown (warning) — INHIBITED by DatacenterDown
ServiceDown (warning) — INHIBITED by DatacenterDown
DiskUsage (warning) — FIRING (different service, not inhibited)
Prevention Tips
- Ensure
equallabels exist on both source and target alerts - Use
severityfor broad inhibition (critical inhibits warning) - Use
alertnamefor specific alert-to-alert inhibition - Test inhibition with
amtoolbefore deploying - Document inhibition rules in your runbook
Common Mistakes with alertmanager inhibit
- Forgetting that lazy evaluation defers computation until the value is forced, causing space leaks with unevaluated thunks
- Using
returnto exit a function early instead of wrapping a pure value in the monad - Mixing let bindings with <- bindings in do notation, producing type errors
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
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro