AmneziaWG exporter is a Prometheus exporter for gathering AmneziaWG client connection metrics.
amneziawg-exporter can optionally identify WireGuard clients using a client table. If this feature is enabled, clients are identified by their names; otherwise, they are marked as "unidentified."
amneziawg-exporter has three operating modes (AWG_EXPORTER_OPS_MODE
environment variable):
http
- Run an HTTP server onAWG_EXPORTER_HTTP_PORT
to make metrics accessible, like most exporters. Defaultmetricsfile
- Write metrics toAWG_EXPORTER_METRICS_FILE
instead of serving them on an HTTP port.oneshot
- Same as inmetricsfile
mode, but the service creates a metrics file and then shuts down. In Docker, you can use a volume to save the file on disk. It can then be used by node-exporter to serve your exporter metrics.grafana_cloud
- Sends metrics directly to Grafana Cloud using the provided API URL and token.
Tip
Open this link to read more about the textfile collector.
The following environment variables can be used to configure amneziawg-exporter.
Variable Name | Default Value | Description |
---|---|---|
AWG_EXPORTER_SCRAPE_INTERVAL | 60 | Interval for scraping WireGuard metrics (for the http mode). |
AWG_EXPORTER_HTTP_PORT | 9351 | Port for HTTP service. |
AWG_EXPORTER_LISTEN_ADDR | 0.0.0.0 | Listen address for HTTP service. |
AWG_EXPORTER_METRICS_FILE | /tmp/prometheus/awg.prom | Path to the metrics file for Node exporter textfile collector. |
AWG_EXPORTER_OPS_MODE | http | Operation mode for the exporter (http , metricsfile , oneshot or grafana_cloud ). |
AWG_EXPORTER_AWG_SHOW_EXEC | "awg show all dump" | Command to run the awg show command. |
AWG_GRAFANA_WRITE_URL | URL for sending metrics to Grafana Cloud (for grafana_cloud mode). |
|
AWG_GRAFANA_WRITE_TOKEN | Authorization token for Grafana Cloud (for grafana_cloud mode). |
|
AWG_GRAFANA_ADDITIONAL_LABELS | Additional labels to add when sending metrics to Grafana Cloud. | |
AWG_EXPORTER_REDIS_HOST | localhost | Redis server host to store peers data |
AWG_EXPORTER_REDIS_PORT | 6379 | Redis server port to store peers data |
AWG_EXPORTER_REDIS_DB | 0 | Redis server db number to store peers data |
Metric name | Labels | Description |
---|---|---|
awg_current_online | Current number of online users. | |
awg_dau | Daily active users. | |
awg_mau | Monthly active users. | |
awg_status | Exporter status. 1 - OK, 0 - not OK |
The Docker image is built using the Dockerfile available in this repository. You can easily obtain it from DockerHub by running the command docker pull amneziavpn/amneziawg-exporter.
You can use example docker-compose.yml with Docker Compose v2 to run AmneziaWG exporter:
# docker compose up -d
[+] Running 3/3
✔ Network amneziawg-exporter_default Created 0.2s
✔ Container amneziawg-exporter-redis Started 0.1s
✔ Container amneziawg-exporter Started 0.1s
# docker compose ps
NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS
amneziawg-exporter amneziavpn/amneziawg-exporter:latest "/exporter.py" amneziawg-exporter 15 seconds ago Up 14 seconds 0.0.0.0:9351->9351/tcp, :::9351->9351/tcp
amneziawg-exporter-redis redis:alpine "docker-entrypoint.s…" amneziawg-exporter-redis 15 seconds ago Up 14 seconds 6379/tcp
Tip
Run docker compose build
before, if you want to build image by yourself.