feat(monitoring): alert gaps, inhibition rules and probe mail retry #703

Sammanfogat
supernaut sammanfogade 10 incheckningar från feat/monitoring-alerts in i main 2026-10-13 07:52:33 +00:00
Ägare

What

Eight monitoring changes, one commit each.

  • The cross-probe email now retries. send_mail returns non-zero when SMTP is unset or curl fails. The state file is written only after a delivered email.

  • ServicesHostAgentSilent (critical, 10m) fires when up{job="node",host="<services host>"} is absent. The host label is one variable, monitoring_services_host_label, shared by the agent role and the rules. The value is unchanged (bitborg-prod), so no series are renewed.

  • Alertmanager inhibition rules. A silent services host holds back its per-service alerts. New BackupVolumeUnmounted holds back Backup*Stale. test-alert-rules.py now runs amtool check-config and fails on an inhibit matcher that names no alert.

  • ReconcileEventPathSilent now matches the systemd Starting bitborg-reconcile-kick.service line under user@<bitborg_user_uid>.service. User units have no unit label of their own. The uid does not change with the OS user rename.

  • RunnerControllerLoopFailing and RunnerControllerStalled read the controller textfile. The controller container joins monitoring_core_units. The stale comment about queued_jobs=-1 is corrected.

  • VacuousAlertRule fires when a rule's series_fetched is 0 for 30m. The rule name is copied to a rule label because the alert's own alertname replaces the series label. ServicesHostAgentSilent inhibits VacuousAlertRule, which would otherwise fire about 30 times when the agent is silent. test-alert-rules.py evaluates the inhibit rules against label sets, including this pair. alert_vacuity_exempt holds ServicesHostAgentSilent, which fetches nothing while it fires.

  • RenovateStale reads the last-run timestamp (limit alert_renovate_max_age_hours, 48).

  • ForgejoMissingTranslation is a Loki rule. It excludes the relativetime.* plural-form lookups, which Forgejo logs about 100k times a day.

The Alertmanager scrape job and AlertmanagerDeliveryFailing already exist (#593), so #461 needed only the inhibition rules.

Verification

  • check-alert-rules.py (and --self-test), test-alert-rules.py, test-monitoring-probe.py: pass.
  • Unit cases for ServicesHostAgentSilent and BackupVolumeUnmounted (fires, quiet). The probe test stubs curl for six send/state cases and fails on the old script.
  • Live (read-only): absent(up{job="node",host="bitborg-prod"}) returns nothing, and returns one series for a wrong host. Same for the BackupVolumeUnmounted expression with the real and a wrong mountpoint.
  • Live (read-only), per rule: each new expression returns nothing today and returns series with a loosened control. VacuousAlertRule finds 0 vacuous rules and 33 with == 1. ForgejoMissingTranslation matches 0 lines in 15m, 1582 without the exclusion.
  • Rendered probe script passes pinned shellcheck 0.10.0. ansible-lint and --syntax-check pass.

A failed cross-probe mail makes bitborg-monitoring-probe.service exit non-zero on each retry tick. This is intended and documented in the runbook. No alert is added for it.

Not verified

  • No apply. Stopping vmagent on staging to watch the alert fire is still to do after apply.
  • ForgejoMissingTranslation cannot fire on today's data, so only the line filters are tested.
  • Whether node_exporter drops the backup mountpoint on unmount is expected, not observed.

Apply

./scripts/apply-reconcile.sh -- --tags monitoring,monitoring-agent

monitoring restarts vmalert, Alertmanager and reloads the Loki rules. monitoring-agent rewrites the probe script and the unit-metrics script (runner controller is a new core unit).

Closes #609
Closes #605
Closes #461
Closes #580
Closes #602
Closes #444
Closes #330
Closes #335

## What Eight monitoring changes, one commit each. - The cross-probe email now retries. `send_mail` returns non-zero when SMTP is unset or curl fails. The state file is written only after a delivered email. - `ServicesHostAgentSilent` (critical, 10m) fires when `up{job="node",host="<services host>"}` is absent. The host label is one variable, `monitoring_services_host_label`, shared by the agent role and the rules. The value is unchanged (`bitborg-prod`), so no series are renewed. - Alertmanager inhibition rules. A silent services host holds back its per-service alerts. New `BackupVolumeUnmounted` holds back `Backup*Stale`. `test-alert-rules.py` now runs `amtool check-config` and fails on an inhibit matcher that names no alert. - `ReconcileEventPathSilent` now matches the systemd `Starting bitborg-reconcile-kick.service` line under `user@<bitborg_user_uid>.service`. User units have no `unit` label of their own. The uid does not change with the OS user rename. - `RunnerControllerLoopFailing` and `RunnerControllerStalled` read the controller textfile. The controller container joins `monitoring_core_units`. The stale comment about `queued_jobs=-1` is corrected. - `VacuousAlertRule` fires when a rule's `series_fetched` is 0 for 30m. The rule name is copied to a `rule` label because the alert's own `alertname` replaces the series label. `ServicesHostAgentSilent` inhibits `VacuousAlertRule`, which would otherwise fire about 30 times when the agent is silent. `test-alert-rules.py` evaluates the inhibit rules against label sets, including this pair. `alert_vacuity_exempt` holds `ServicesHostAgentSilent`, which fetches nothing while it fires. - `RenovateStale` reads the last-run timestamp (limit `alert_renovate_max_age_hours`, 48). - `ForgejoMissingTranslation` is a Loki rule. It excludes the `relativetime.*` plural-form lookups, which Forgejo logs about 100k times a day. The Alertmanager scrape job and `AlertmanagerDeliveryFailing` already exist (#593), so #461 needed only the inhibition rules. ## Verification - `check-alert-rules.py` (and `--self-test`), `test-alert-rules.py`, `test-monitoring-probe.py`: pass. - Unit cases for `ServicesHostAgentSilent` and `BackupVolumeUnmounted` (fires, quiet). The probe test stubs `curl` for six send/state cases and fails on the old script. - Live (read-only): `absent(up{job="node",host="bitborg-prod"})` returns nothing, and returns one series for a wrong host. Same for the `BackupVolumeUnmounted` expression with the real and a wrong mountpoint. - Live (read-only), per rule: each new expression returns nothing today and returns series with a loosened control. `VacuousAlertRule` finds 0 vacuous rules and 33 with `== 1`. `ForgejoMissingTranslation` matches 0 lines in 15m, 1582 without the exclusion. - Rendered probe script passes pinned shellcheck 0.10.0. ansible-lint and `--syntax-check` pass. A failed cross-probe mail makes `bitborg-monitoring-probe.service` exit non-zero on each retry tick. This is intended and documented in the runbook. No alert is added for it. ## Not verified - No apply. Stopping vmagent on staging to watch the alert fire is still to do after apply. - `ForgejoMissingTranslation` cannot fire on today's data, so only the line filters are tested. - Whether node_exporter drops the backup mountpoint on unmount is expected, not observed. ## Apply ```bash ./scripts/apply-reconcile.sh -- --tags monitoring,monitoring-agent ``` `monitoring` restarts vmalert, Alertmanager and reloads the Loki rules. `monitoring-agent` rewrites the probe script and the unit-metrics script (runner controller is a new core unit). Closes #609 Closes #605 Closes #461 Closes #580 Closes #602 Closes #444 Closes #330 Closes #335
supernaut lade till 10 incheckningar 2026-10-13 06:31:55 +00:00
send_mail now returns a non-zero status when SMTP is unset or curl fails.
The probe writes its state file only after a delivered email, so the next run retries.

Closes #609
ServicesHostAgentSilent fires when up{job="node"} for the services host is absent for 10m.
The staleness rules return nothing without their series, so they cannot cover a dead agent.
The host label is now one variable shared by the agent role and the rules.

Closes #605
A silent services host inhibits its per-service alerts.
BackupVolumeUnmounted inhibits the backup staleness alerts.
test-alert-rules.py now runs amtool check-config and fails on an inhibit matcher that names no alert.

Closes #461
User units log under user@<uid>.service, so the old unit selector matched nothing.
The right side now matches the systemd Starting line and uses bitborg_user_uid.

Closes #580
RunnerControllerLoopFailing and RunnerControllerStalled read the controller's own textfile.
The controller container joins monitoring_core_units.
The queued_jobs comment now names the rules that cover the -1 sentinel.

Closes #602
VacuousAlertRule reads vmalert's per-rule series_fetched and fires when it is 0 for 30m.
The rule name is copied to a rule label because the alert's own alertname replaces the series label.
alert_vacuity_exempt lists ServicesHostAgentSilent, which fetches nothing while it fires.

Closes #444
RenovateStale reads the last-run timestamp, because the status metric is sticky and keeps its last value.
The limit is alert_renovate_max_age_hours (48).

Closes #330
ForgejoMissingTranslation is a Loki rule on the Missing translation error line.
It excludes the relativetime plural-form lookups that upstream logs on every page view.
test-alert-rules.py now honours negated line filters.

Closes #335
About 30 VacuousAlertRule alerts fire at once when the agent goes silent and bury ServicesHostAgentSilent.
The inhibit rule has no equal because those alerts carry no host label.
test-alert-rules.py now evaluates inhibit rules against label sets.
docs(monitoring): say what a failed cross-probe unit means
Alla kontroller lyckades
ci / ci (pull_request) Successful in 2m58s
e7474026f7
supernaut tvångsskickade feat/monitoring-alerts från e7474026f7
Alla kontroller lyckades
ci / ci (pull_request) Successful in 2m58s
till 7c05cebaaa
Alla kontroller lyckades
ci / ci (pull_request) Successful in 2m59s
2026-10-13 07:25:46 +00:00
Jämför
supernaut sammanfogade incheckning d35ba2adde till main 2026-10-13 07:52:33 +00:00
supernaut tog bort grenen feat/monitoring-alerts 2026-10-13 07:52:33 +00:00
Logga in för att delta i denna konversation.
Inga granskare
Ingen milstolpe
Inget projekt
Inga tilldelade
1 deltagare
Notiser
Förfallodatum
Förfallodatumet är ogiltigt eller utanför gränserna. Använd formatet "åååå-mm-dd".

Inget förfallodatum satt.

Beroenden

Inga beroenden satta

Referens
bitborg/bitborg-infra!703
Ingen beskrivning angiven.