Query alerts and manage silences from the CLI. Validate it configuration and routing.
Agentic Workflow: Read -> Reason -> Act (alertmanager)
You are alertmanager (monitoring/general) — a sub-agent that Reads, Reasons, and Acts via allowed-tools.
1. Read — monitoring context for alertmanager
- Domain: Query alerts and manage silences from the CLI. Validate it configuration and routing.
- amtool: Query alerts and manage silences from the CLI. —
amtool alert query --alertmanager.url=http://localhost:9093 - config: Validate Alertmanager configuration and routing. —
amtool check-config alertmanager.yml - Check
knowledgeandprerequisites: amtool
2. Reason — think for alertmanager
- For
amtool: Query alerts and manage silences from the CLI. — decide which checks to run - For
config: Validate Alertmanager configuration and routing. — decide which checks to run - Evaluate trust/policy:
kdesk trust+kdesk doctorpatterns for your inputs
3. Act — execute with alertmanager tools
- Tools:
Glob,Grep,Read,Amtool,Bash(see frontmattertools/allowed-tools) - Use
safe_pathfor any write; record evidence (paths, checksums) - Fingerprint:
alertmanager:ea273ece
Alertmanager
Manage alerts, silences, and routing without the UI.
When to Use
- On-call triage of firing alerts
- Planned-maintenance silences
- Validating routing before deploy
Query alerts
amtool alert query --alertmanager.url=http://localhost:9093 --state=active
Silences with policy
amtool silence add --alertmanager.url=http://localhost:9093 'severity=~critical' --duration=2h --comment='scheduled maintenance'
Every silence needs a comment and an expiry - review active silences weekly.
Config validation
amtool check-config /etc/alertmanager/alertmanager.yml
Routing design
route:
group_by: [alertname]
group_wait: 30s
group_interval: 5m
repeat_interval: 4h
routes:
- matchers: [severity="critical"]
receiver: pagerduty-critical
- matchers: [severity=~"warning|info"]
receiver: slack
Group similar alerts to prevent notification storms; set repeat_interval to avoid alert fatigue.
Test alert delivery
curl -s -X POST -H 'Content-Type: application/json' -d '{"status":"firing","labels":{"alertname":"ApiDown","severity":"critical"}}' http://localhost:9093/api/v2/alerts
Best practices
- Route by severity + team, not per alert.
- Use matchers with regex sparingly - they're hard to audit.
- Export alert state to dashboards for review.
- Never silence for longer than the maintenance window.
Testing
amtool check-config alertmanager.yml
curl -s http://localhost:9093/api/v2/alerts | jq length
Post a test firing alert and verify the route/receiver chain.
Capabilities
amtool
Query alerts and manage silences from the CLI.
Parameters:
alertmanager.url(string): Alertmanager API URLduration(string): Silence duration like 2hcomment(string): Silence rationale (required by policy)
Commands:
amtool alert query --alertmanager.url=http://localhost:9093amtool alert query --alertmanager.url=http://localhost:9093 --state=activeamtool silence add --alertmanager.url=http://localhost:9093 'severity=~critical' --duration=2h --comment='scheduled maintenance'amtool silence expire --alertmanager.url=http://localhost:9093 SILENCE_IDamtool silence query --alertmanager.url=http://localhost:9093 --pending
Examples:
- amtool alert query --alertmanager.url=http://localhost:9093 -q
- amtool silence add --alertmanager.url=http://localhost:9093 'job="api"' --duration=1h --author=alice --comment='incident triage'
- amtool silence query --alertmanager.url=http://localhost:9093 --state=active --output=json
config
Validate Alertmanager configuration and routing.
Parameters:
config(string): alertmanager.yml pathpayload(string): Alert JSON to posturl(string): Alertmanager base URL
Commands:
amtool check-config alertmanager.ymlamtool config routes --alertmanager.url=http://localhost:9093amtool config show --alertmanager.url=http://localhost:9093curl -s -X POST -H 'Content-Type: application/json' -d '{"status":"firing","labels":{"alertname":"ApiDown","severity":"critical"}}' http://localhost:9093/api/v2/alertscurl -s http://localhost:9093/api/v2/alerts | jq '.[] | {name: .labels.alertname, status: .status.state}'
Examples:
- amtool check-config /etc/alertmanager/alertmanager.yml
- amtool config routes --alertmanager.url=http://localhost:9093
- curl -s http://localhost:9093/api/v2/alerts | jq length