Authors and tests Prometheus alerting rules and Alertmanager config: rule files, promtool validation, unit tests, silences, and the HTTP API.
Agentic Workflow: Read -> Reason -> Act (alerting-rules)
You are Alerting Rules (api/general) — a sub-agent that Reads, Reasons, and Acts via allowed-tools.
1. Read — api context for alerting-rules
- Domain: Authors and tests Prometheus alerting rules and Alertmanager config: rule files, promtool validation, unit tests, silences, and the HTTP API.
- rules-authoring: Author Prometheus alerting/recording rules and validate them. —
promtool check rules alerting-rules.yml
- alertmanager: Configure Alertmanager routing, manage silences, and inspect the API. —
amtool check-config /etc/alertmanager/alertmanager.yml
- Check
knowledge and prerequisites: amtool, promtool
2. Reason — think for alerting-rules
- For
rules-authoring: Author Prometheus alerting/recording rules and validate them. — decide which checks to run
- For
alertmanager: Configure Alertmanager routing, manage silences, and inspect the API. — decide which checks to run
- Evaluate trust/policy:
kdesk trust + kdesk doctor patterns for your inputs
3. Act — execute with alerting-rules tools
- Tools:
Glob, Grep, Read, Bash, Amtool (see frontmatter tools/allowed-tools)
- Use
safe_path for any write; record evidence (paths, checksums)
- Fingerprint:
alerting-rules:1481fe5a
Alerting Rules
What this skill does
Authors and operates Prometheus alerting: rule files, promtool validation and unit tests, Alertmanager routing and silences, and alert state queries via the HTTP API.
When to use
- Creating an alert for a new SLO or error condition
- Debugging an alert that fires (or fails to fire)
- Managing an outage via silences without stopping metrics collection
Real commands
# Validate rules
promtool check rules alerts.yml
# Unit-test rule evaluation
promtool test rules tests.yml
# Inspect live alert state
curl -s 'http://localhost:9090/api/v1/rules?type=alert' | jq '.data.groups[].rules[] | {name,state}'
# Alertmanager
amtool check-config alertmanager.yml
amtool alert list
amtool silence add --expires=2h --author=oncall 'severity="critical"'
Rules file
groups:
- name: api
rules:
- alert: APIHighErrorRate
expr: sum(rate(http_requests_total{status=~"5.."}[5m])) / sum(rate(http_requests_total[5m])) > 0.05
for: 5m
labels:
severity: critical
annotations:
summary: "API 5xx rate above 5%"
Unit test
rule_files: [alerts.yml]
evaluation_interval: 1m
tests:
- interval: 1m
input_series:
- series: 'http_requests_total{status="500"}'
values: '0+10x10'
alert_rule_test:
- eval_time: 10m
alertname: APIHighErrorRate
Testing
- Run
promtool check rules in CI before merge
- Write promtool test rules cases for fire/no-fire thresholds
Best practices
- Prefer SLO burn-rate alerts over raw thresholds
- Every alert needs a runbook URL in annotations
- Use
for: clauses to avoid flapping
Capabilities
rules-authoring
Author Prometheus alerting/recording rules and validate them.
Parameters:
rules_file (string): Path to the alerting rules YAML
test_file (string): Path to promtool unit test YAML
query (string): PromQL expression to evaluate
Commands:
promtool check rules alerting-rules.yml
promtool test rules rules.test.yml
promtool query instant 'up'
promtool query range 'http_requests_total[5m]'
curl 'http://localhost:9090/api/v1/rules?type=alert'
Examples:
- promtool check rules /etc/prometheus/alerts.yml
- promtool test rules unit-tests.yml
- curl -s 'http://localhost:9090/api/v1/rules' | jq '.data.groups[].rules[] | {name, state}'
alertmanager
Configure Alertmanager routing, manage silences, and inspect the API.
Parameters:
expires (string): Silence duration, e.g. 1h
author (string): Silence creator name
matchers (string): Label matchers like severity="critical"
Commands:
amtool check-config /etc/alertmanager/alertmanager.yml
amtool alert list
amtool silence add --expires=1h 'severity="critical"'
amtool silence list
curl -X POST http://localhost:9093/api/v2/silences -d @silence.json
Examples:
- amtool check-config /etc/alertmanager/alertmanager.yml
- amtool silence add --author=oncall --comment="draining node" 'instance="node1"'
- curl -X GET http://localhost:9093/api/v2/alerts | jq '.[].labels.alertname'
References
1---2name: "alerting-rules"3description: "Authors and tests Prometheus alerting rules and Alertmanager config: rule files, promtool validation, unit tests, silences, and the HTTP API. Use when working with rules authoring, alertmanager, api or when the user mentions rules authoring, alertmanager, api."4license: "MIT"5compatibility: "Requires amtool, promtool. Needs network access."6metadata:7 source: https://skillmd.com/skills/opknock/alerting-rules8 author: Kdesk9 version: 2.0.010 category: api11allowed-tools: "Glob Grep Read Bash(amtool:*) Bash(curl:*) Bash(promtool:*)"12---1314Authors and tests Prometheus alerting rules and Alertmanager config: rule files, promtool validation, unit tests, silences, and the HTTP API.1516## Agentic Workflow: Read -> Reason -> Act (alerting-rules)1718You are **Alerting Rules** (api/general) — a sub-agent that **Reads, Reasons, and Acts** via `allowed-tools`.1920### 1. Read — api context for `alerting-rules`21- Domain: Authors and tests Prometheus alerting rules and Alertmanager config: rule files, promtool validation, unit tests, silences, and the HTTP API.22- **rules-authoring**: Author Prometheus alerting/recording rules and validate them. — `promtool check rules alerting-rules.yml`23- **alertmanager**: Configure Alertmanager routing, manage silences, and inspect the API. — `amtool check-config /etc/alertmanager/alertmanager.yml`24- Check `knowledge` and `prerequisites: amtool, promtool`2526### 2. Reason — think for `alerting-rules`27- For `rules-authoring`: Author Prometheus alerting/recording rules and validate them. — decide which checks to run28- For `alertmanager`: Configure Alertmanager routing, manage silences, and inspect the API. — decide which checks to run29- Evaluate trust/policy: `kdesk trust` + `kdesk doctor` patterns for your inputs3031### 3. Act — execute with `alerting-rules` tools32- Tools: `Glob`, `Grep`, `Read`, `Bash`, `Amtool` (see frontmatter `tools`/`allowed-tools`)33- Use `safe_path` for any write; record evidence (paths, checksums)34- Fingerprint: `alerting-rules:1481fe5a`3536# Alerting Rules3738## What this skill does3940Authors and operates Prometheus alerting: rule files, promtool validation and unit tests, Alertmanager routing and silences, and alert state queries via the HTTP API.4142## When to use4344- Creating an alert for a new SLO or error condition45- Debugging an alert that fires (or fails to fire)46- Managing an outage via silences without stopping metrics collection4748## Real commands4950```bash51# Validate rules52promtool check rules alerts.yml5354# Unit-test rule evaluation55promtool test rules tests.yml5657# Inspect live alert state58curl -s 'http://localhost:9090/api/v1/rules?type=alert' | jq '.data.groups[].rules[] | {name,state}'5960# Alertmanager61amtool check-config alertmanager.yml62amtool alert list63amtool silence add --expires=2h --author=oncall 'severity="critical"'64```6566## Rules file6768```yaml69groups:70- name: api71 rules:72 - alert: APIHighErrorRate73 expr: sum(rate(http_requests_total{status=~"5.."}[5m])) / sum(rate(http_requests_total[5m])) > 0.0574 for: 5m75 labels:76 severity: critical77 annotations:78 summary: "API 5xx rate above 5%"79```8081## Unit test8283```yaml84rule_files: [alerts.yml]85evaluation_interval: 1m86tests:87- interval: 1m88 input_series:89 - series: 'http_requests_total{status="500"}'90 values: '0+10x10'91 alert_rule_test:92 - eval_time: 10m93 alertname: APIHighErrorRate94```9596## Testing9798- Run `promtool check rules` in CI before merge99- Write promtool test rules cases for fire/no-fire thresholds100101## Best practices102103- Prefer SLO burn-rate alerts over raw thresholds104- Every alert needs a runbook URL in annotations105- Use `for:` clauses to avoid flapping106107## Capabilities108109### rules-authoring110Author Prometheus alerting/recording rules and validate them.111112**Parameters:**113- `rules_file` (string): Path to the alerting rules YAML114- `test_file` (string): Path to promtool unit test YAML115- `query` (string): PromQL expression to evaluate116117**Commands:**118- `promtool check rules alerting-rules.yml`119- `promtool test rules rules.test.yml`120- `promtool query instant 'up'`121- `promtool query range 'http_requests_total[5m]'`122- `curl 'http://localhost:9090/api/v1/rules?type=alert'`123124**Examples:**125- promtool check rules /etc/prometheus/alerts.yml126- promtool test rules unit-tests.yml127- curl -s 'http://localhost:9090/api/v1/rules' | jq '.data.groups[].rules[] | {name, state}'128129### alertmanager130Configure Alertmanager routing, manage silences, and inspect the API.131132**Parameters:**133- `expires` (string): Silence duration, e.g. 1h134- `author` (string): Silence creator name135- `matchers` (string): Label matchers like severity="critical"136137**Commands:**138- `amtool check-config /etc/alertmanager/alertmanager.yml`139- `amtool alert list`140- `amtool silence add --expires=1h 'severity="critical"'`141- `amtool silence list`142- `curl -X POST http://localhost:9093/api/v2/silences -d @silence.json`143144**Examples:**145- amtool check-config /etc/alertmanager/alertmanager.yml146- amtool silence add --author=oncall --comment="draining node" 'instance="node1"'147- curl -X GET http://localhost:9093/api/v2/alerts | jq '.[].labels.alertname'148149## References150- [Alerting Rules](https://prometheus.io/docs/prometheus/latest/configuration/alerting_rules/)151- [Alertmanager](https://prometheus.io/docs/alerting/latest/alertmanager/)152- [promtool](https://prometheus.io/docs/prometheus/latest/command-line/promtool/)153- [Alerting on SLOs](https://sre.google/workbook/alerting-on-slos/)