feat(rosenpass): alert on a vanished Link B series and on the UPnP mapping

Link B (rpi wg-remote <-> linode wg0) depends on a permanent UPnP mapping
UDP 9999 -> 192.168.1.125:9999 for its inbound path, and the 15-minute
rosenpass-upnp.timer only logged to the journal when it could not re-assert
it. Two gaps closed:

* RosenpassPskRotationStalled gains absent(rosenpass_psk_rotation_age_seconds
  {node="rpi", interface="wg-remote"}). Without it a dead metrics timer or
  script on the Pi silently dropped the Link B series while the rule kept
  reading healthy. No siriussec/wg-remote arm: that interface does not exist
  there.

* rosenpass-upnp.sh now stamps its result to /run/rosenpass-upnp.present (1/0)
  and rosenpass-metrics.sh reads that file into rosenpass_upnp_mapping_present
  {node="rpi"} plus rosenpass_upnp_last_check_timestamp_seconds. The 60 s
  metrics timer never calls upnpc (that would poll the IGD 1440x/day); a host
  without the state file (siriussec) emits neither series. New
  RosenpassUpnpMappingLost alert fires on value 0, on a state file older than
  30 minutes (stopped timer / hung IGD, so a stale 1 cannot read healthy), or
  on a missing series.
This commit is contained in:
Lance Walters 2026-12-03 02:52:58 -05:00
commit d1343bbbc3
4 changed files with 120 additions and 15 deletions

View file

@ -44,6 +44,8 @@ Arch (siriussec).
rosenpass_unit_active{node="rpi|siriussec"} 0|1
rosenpass_psk_rotation_age_seconds{node=...,interface="wg0|wg-remote"}
rosenpass_psk_rotation_last_change_timestamp_seconds{node=...,interface="wg0|wg-remote"}
rosenpass_upnp_mapping_present{node="rpi"} 0|1
rosenpass_upnp_last_check_timestamp_seconds{node="rpi"}
```
One series set per interface: `wg0` is Link A and `wg-remote` is Link B, and an
@ -51,7 +53,17 @@ interface absent on that host (wg-remote on siriussec, where it does not exist)
is skipped. `RosenpassPskRotationStalled` is interface-agnostic
(`max by (node, interface) ... > 900`), so a stalled Link B pages as soon as the
`wg-remote` series exists — which is why hashing only `wg0` left Link B
unobserved.
unobserved. Its `absent()` arms name `rpi/wg0`, `rpi/wg-remote` and
`siriussec/wg0`, so a vanished Link B series pages too while siriussec never
claims a `wg-remote` it does not have.
`rosenpass_upnp_mapping_present` is the state `rosenpass-upnp.sh` stamped on its
last 15-minute run (`/run/rosenpass-upnp.present`, `1`/`0`), and
`rosenpass_upnp_last_check_timestamp_seconds` is that file's mtime — so a
stopped timer reads as stale rather than as a flat healthy `1`. The 60-second
metrics timer only reads the file; it never calls `upnpc`, which would poll the
router's IGD 1440 times a day. Where the state file does not exist (siriussec)
neither series is emitted.
The script hashes the output of `wg show <interface> preshared-keys` and stores
only the SHA-256 digest plus the last-change timestamp in
@ -81,13 +93,15 @@ 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.
so a missing series alerts instead of reading as healthy. Both cover **Link A
and Link B**: the rotation rule keys on `(node, interface)`, and its `absent()`
arms name `rpi/wg0`, `rpi/wg-remote` and `siriussec/wg0`.
`RosenpassPskRotationStalled` keys on `(node, interface)`, so it covers Link B
(`interface="wg-remote"`) as soon as that series exists — no rule change needed.
The `absent()` arms still name `wg0` only, so a *disappeared* `wg-remote` series
is currently silent; adding that arm plus a metric for the UPnP mapping below is
the remaining gap.
A third rule, `RosenpassUpnpMappingLost` (`severity: warning`, 10 m), covers
Link B's single inbound path: it fires when
`rosenpass_upnp_mapping_present == 0`, when no `rosenpass-upnp` run has stamped
the state for over 30 minutes (stopped timer, hung IGD), or when the series is
absent altogether.
## Link B (rpi wg-remote ↔ linode wg0)