Repository navigation
feat(status): write per-user stats to a textfile (#1) - #11
Merged
Merged
Conversation
usher had no way to show which users connect and how much traffic they move. awg-grpc and Xray both report it, but only usher maps a key or an email to a user name. Each pass now writes a Prometheus text exposition file that the node_exporter textfile collector serves, so usher keeps no listener. The file is backend-neutral: AmneziaWG and Xray users get the same four metrics, usher_interface_up, usher_user_online and the uplink and downlink byte counters, labelled by user and interface. Session gains Stats; AWG maps ListPeers, with online as a handshake under 180 s, and Xray maps StatsService counters and GetAllOnlineUsers. Metrics are a side channel: a stats error drops that interface's users from the file and never fails the interface or blocks reconcile. usher checks the Xray config for the stats switches and logs the missing ones instead of writing zeros. USHER_STATUS_DIR turns the file on; unset, usher behaves as before.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
usher had no way to show which users connect and how much traffic they move. awg-grpc and Xray report it, but only usher maps a key or an email to a user name. Issue #1 covered AmneziaWG only; the Xray backend landed after it.
Change
<USHER_STATUS_DIR>/usher.promin Prometheus text format for node_exporter's textfile collector. UnsetUSHER_STATUS_DIRkeeps the old behaviour.{interface, user}:usher_interface_up,usher_user_online,usher_user_uplink_bytes_total,usher_user_downlink_bytes_total.Session.Stats: AWG mapsListPeers(online = handshake under 180 s); Xray mapsQueryStatsandGetAllOnlineUsers.Differences from the issue: Xray is covered; "connected" is computed by usher (
usher_user_online) instead of a PromQL query, because Xray has no handshake time; there is no handshake or pass-timestamp metric (last seen comes from the history ofusher_user_online, staleness fromnode_textfile_mtime_seconds); the file is written through the existingatomicfile.Write; the directory is opt-in by env, not probed.Semantics per backend are in the README
## Statssection anddocs/xray.md.Verification
go test -race ./...andscripts/format.shpass locally.statsstep; they have not run outside CI yet, so this PR'se2ejob is their first run.Closes #1
Per-task commits before collapse