diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6cb5d6b..8bb8864 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,9 +1,30 @@ name: ci +# No test reads these paths. Keep both lists equal. on: pull_request: + paths-ignore: + - "**.md" + - "docs/**" + - "LICENSE" + - "logo.png" + - ".zed/**" + - "deploy/compose.example.yml" + - "deploy/xray/**" + - "deploy/usher/**" + - ".github/workflows/release.yml" push: branches: [master] + paths-ignore: + - "**.md" + - "docs/**" + - "LICENSE" + - "logo.png" + - ".zed/**" + - "deploy/compose.example.yml" + - "deploy/xray/**" + - "deploy/usher/**" + - ".github/workflows/release.yml" permissions: contents: read diff --git a/README.md b/README.md index 1f81bd5..1d6b0cb 100644 --- a/README.md +++ b/README.md @@ -166,11 +166,17 @@ mean different things: | | AmneziaWG | Xray | | ---------------- | -------------------------------------------------- | ------------------------------------------------ | -| online | a handshake less than 180 s ago: 1 while the tunnel is up, 0 up to 180 s after the client disconnects | at least one open proxied connection; an idle client reads 0 | +| online | a handshake less than 180 s ago; a sleeping phone reads 0 | at least one open proxied connection; an idle client reads 0 | | bytes | encrypted packets, keepalives included | proxied payload | | counters reset | when the peer is recreated or the interface restarts | when Xray restarts | | users in the file | users of the interface in `usher.yml` that have a peer | every user of the inbound in `usher.yml` | +An AmneziaWG client handshakes about every 2 minutes while it sends packets, and the +`PersistentKeepalive = 25` of its config keeps it sending while the device is awake. A phone that +sleeps sends no keepalive: it reads 0 while its app still shows the tunnel on, and 1 for a few +minutes each time it wakes. 180 s is the WireGuard key lifetime; a session without a newer +handshake carries no traffic after it. A disconnected client reads 0 at most 180 s later. + `rate()` and `increase()` handle the counter resets. A user gets series only on the interfaces `usher.yml` lists for that user. When usher cannot read the stats of an interface, it logs `reading stats` and leaves the users of that interface out of the file: a missing series diff --git a/docs/operations.md b/docs/operations.md index e28d45f..af127c7 100644 --- a/docs/operations.md +++ b/docs/operations.md @@ -35,9 +35,41 @@ usher writes the file with mode `0644`. A node_exporter that runs as another use reads only `*.prom` files, so it skips the temporary file of a write in progress. A pass that stops early, for example on a `users.json` error, or that a stop signal interrupts, -writes no file, and the file keeps the previous content. node_exporter's -`node_textfile_mtime_seconds` for the file then stops moving; usher writes no timestamp of its own. -A write error is logged as `writing status file`. +writes no file, and the file keeps the previous content. A stopped usher leaves it the same way. +node_exporter keeps serving that content, so every interface still reads 1. usher writes no +timestamp of its own; node_exporter's `node_textfile_mtime_seconds` for the file stops moving. A +write error is logged as `writing status file`. -When every backend is down, usher still writes the file, but it holds no series. Alert on -`absent(usher_interface_up)` as well. +### Alerts + +usher reports most failures by leaving series out, so a rule on `usher_interface_up == 0` alone +misses them: + +- The interfaces of a backend that is down are absent. The other backend keeps + `usher_interface_up` present, so `absent(usher_interface_up)` fires only when every backend is + down and the file holds no series. Each interface needs an `absent` rule of its own. +- A stale file keeps its last values. Only its age shows the failure. + +```yaml +groups: + - name: usher + rules: + - alert: UsherInterfaceDown + expr: usher_interface_up == 0 + for: 2m + - alert: UsherInterfaceAbsent + expr: >- + absent(usher_interface_up{interface="awg0"}) + or absent(usher_interface_up{interface="vless-reality"}) + for: 2m + - alert: UsherStatusEmpty + expr: absent(usher_interface_up) + for: 2m + - alert: UsherStatusStale + expr: time() - node_textfile_mtime_seconds{file=~".*usher.prom"} > 180 + for: 2m +``` + +`UsherInterfaceAbsent` lists the interface names of the deployment; add a term when you add an +interface to a backend. usher runs a pass at least every 30 s, so 180 s of file age is six missed +passes.