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

@ -19,14 +19,25 @@
# Series, emitted per host, never containing key material (the PSK set is only
# SHA-256 hashed, in a root-only state file):
# rosenpass_unit_active{node="rpi|siriussec"} 0|1
# rosenpass_psk_rotation_age_seconds{node=...,interface="wg0"}
# rosenpass_psk_rotation_last_change_timestamp_seconds{node=...,interface="wg0"}
# 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"}
#
# Both rules carry an absent() arm deliberately: a metric that simply stops
# arriving (timer disabled, script broken, node-exporter down, scrape lost)
# Both rotation rules carry an absent() arm deliberately: a metric that simply
# stops arriving (timer disabled, script broken, node-exporter down, scrape lost)
# must alert, because "nothing happened" is exactly what a healthy rotation
# looks like from Prometheus' side. The absent arms name the two hosts that run
# the timer so linode — which has node-exporter but no rosenpass — does not page.
# looks like from Prometheus' side. The absent arms name the hosts and
# interfaces that actually run the timer — rpi wg0 + wg-remote (Link A + Link B),
# siriussec wg0 (Link A only; it has no wg-remote) — so linode, which has
# node-exporter but no rosenpass, and an interface absent from a host do not
# page.
#
# Link B's inbound path is a permanent UPnP mapping on the Pi's router (which
# has no accessible admin panel). rosenpass-upnp.sh re-asserts it every 15 min
# and stamps 1/0 into /run, which rosenpass-metrics.sh turns into the series
# below. Without that mapping the exchange cannot be dialled, the link keeps its
# last PSK and silently stops being post-quantum.
apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
@ -74,6 +85,8 @@ spec:
(
absent(rosenpass_psk_rotation_age_seconds{node="rpi", interface="wg0"})
or
absent(rosenpass_psk_rotation_age_seconds{node="rpi", interface="wg-remote"})
or
absent(rosenpass_psk_rotation_age_seconds{node="siriussec", interface="wg0"})
)
for: 10m
@ -92,3 +105,35 @@ spec:
`journalctl -u rosenpass -n 30` on both rpi and siriussec, and
confirm the Pi still admits 9999/udp from 192.168.1.179
(`sudo ufw status | grep 9999`).
- alert: RosenpassUpnpMappingLost
expr: |
(
max by (node) (rosenpass_upnp_mapping_present) == 0
)
or
(
time() - max by (node) (rosenpass_upnp_last_check_timestamp_seconds) > 1800
)
or
absent(rosenpass_upnp_mapping_present{node="rpi"})
for: 10m
labels:
severity: warning
annotations:
summary: >-
Link B UPnP mapping missing or unverified on {{ $labels.node }}
description: >-
Link B (rpi wg-remote 10.20.0.2 <-> linode wg0 10.20.0.1) can only
be dialled inbound through a permanent UPnP mapping
UDP 9999 -> 192.168.1.125:9999 on the Pi's router, and
rosenpass-upnp.timer re-asserts it every 15 minutes. Either the
last run reported the mapping missing (value 0), no run has
updated the state for over 30 minutes (timer or router IGD gone),
or the series is absent entirely (state file cleared by a reboot,
metrics timer dead). The link keeps passing traffic on its last
preshared key, so this is invisible from the tunnel. On rpi check
`systemctl status rosenpass-upnp.timer`,
`journalctl -t rosenpass-upnp -n 20` and `upnpc -l | grep 9999`;
re-assert by hand with
`sudo systemctl start rosenpass-upnp.service`. If the router
rebooted, the mapping comes back on the next timer run.