docs(rosenpass): record the promtool check/test recipe for the new rules

This commit is contained in:
Lance Walters 2026-12-03 02:22:06 -05:00
commit 0abb02a853

View file

@ -72,3 +72,35 @@ it after the `values.yaml` change is reconciled).
`RosenpassDown` (unit inactive for 5 m) and `RosenpassPskRotationStalled`
(age > 900 s for 10 m), both `severity: warning`, both with `absent()` guards
so a missing series alerts instead of reading as healthy.
## Testing the rules without merging
`kustomize build monitoring/controllers/home` proves the rule renders; these two
prove the PromQL, before Flux ever sees it (a rule that loads but selects
nothing is the failure mode that matters here):
```sh
# 1. syntax + expression validation. promtool wants a bare `groups:` file, so
# strip the CRD wrapper first (PyYAML; jq cannot read YAML).
python3 - <<'PY'
import yaml
d = yaml.safe_load(open('monitoring/controllers/home/rosenpass.yaml'))
yaml.safe_dump({'groups': d['spec']['groups']}, open('/tmp/rosenpass-rules.yaml', 'w'))
PY
kubectl -n monitoring run promtool-check --rm -i --restart=Never \
--image=quay.io/prometheus/prometheus:v3.15.1-distroless \
--command -- /bin/promtool check rules /dev/stdin < /tmp/rosenpass-rules.yaml
```
```sh
# 2. behaviour: promtool test rules with input_series. Mount the rule file and
# a test file (rule_files: [rosenpass-rules.yaml]) from a ConfigMap and check
# four scenarios — healthy (no alerts), one unit down (only that node), age
# over threshold plus a missing peer series, and every series missing (both
# absent() arms). Expect `SUCCESS`. Note promtool compares annotations
# exactly, so expectations have to carry the rendered text.
```
Keep the test file out of the repo: it duplicates the annotation strings, so any
edit to the alerts would have to re-derive it from `rosenpass.yaml`.