Prometheus Alertmanager Silence Not Expiring Fix
In this tutorial, you'll learn about Prometheus Alertmanager Silence Not Expiring Fix. We cover key concepts, practical examples, and best practices.
Your Alertmanager silence did not expire — alerts are still suppressed hours after the silence's endsAt time. The silence matchers are too broad, the time format is UTC but you intended local time, or multiple silences overlap.
The Problem
# Created a silence that should have ended at 18:00 local time
# But used UTC time instead
amtool silence add \
--duration=2h \
--comment="Maintenance window"
If the silence was created at 14:00 local (12:00 UTC), a 2h duration sets endsAt to 14:00 UTC = 16:00 local. The silence "expires" 2 hours early from the user's perspective.
Step-by-Step Fix
1. Use explicit start and end times
# Create silence with explicit UTC timestamps
amtool silence add \
--start="2026-06-24T22:00:00Z" \
--end="2026-06-25T06:00:00Z" \
--comment="Nightly maintenance" \
--author="devops" \
matcher="service=batch-job"
2. Use precise matchers
# Wrong: too broad — silences ALL alerts
amtool silence add --duration=1h matcher="severity=warning"
# Right: specific matchers for targeted silencing
amtool silence add --duration=2h \
matcher="alertname=HighCPUUsage" \
matcher="instance=web-1"
3. Check active silences
# List all silences
amtool silence query \
--alertmanager.url=http://localhost:9093
# List only active silences
amtool silence query \
--alertmanager.url=http://localhost:9093 \
--active
# Check if a specific alert is silenced
amtool alert query \
--alertmanager.url=http://localhost:9093 \
--silenced
4. Expire a silence manually
# Expire a silence by ID
amtool silence expire \
--alertmanager.url=http://localhost:9093 \
<silence-id>
# Bulk expire by matcher
amtool silence query \
--alertmanager.url=http://localhost:9093 \
--matcher="service=batch-job" \
-q | xargs -I{} amtool silence expire {}
5. Use the API for silence management
# Create silence via API
curl -X POST http://localhost:9093/api/v2/silences \
-H "Content-Type: application/json" \
-d '{
"matchers": [
{"name": "alertname", "value": "HighCPUUsage", "isRegex": false}
],
"startsAt": "2026-06-24T10:00:00Z",
"endsAt": "2026-06-24T12:00:00Z",
"createdBy": "admin",
"comment": "Debugging CPU spike"
}'
# List silences
curl http://localhost:9093/api/v2/silences
# Delete silence
curl -X DELETE http://localhost:9093/api/v2/silence/<id>
Expected output:
Silence ID: 1234abcd-5678-efgh-9012-3456abcdef78
Status: Active
Starts: 2026-06-24T22:00:00Z
Ends: 2026-06-25T06:00:00Z
Matchers: service=batch-job
Comment: Nightly maintenance
Created by: devops
Prevention Tips
- Use
--startand--endwith explicit UTC timestamps - Use specific matchers to avoid unintended silencing
- Check active silences before creating new ones
- Use descriptive comments for audit trail
- Set up scheduled maintenance via Alertmanager API
Common Mistakes with alertmanager silence
- Using
foldlinstead offoldl'causing stack overflow on large lists - Forgetting
deriving (Show, Eq)on custom data types needed for debugging - Placing the wildcard pattern first in case expressions, making all subsequent patterns unreachable
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