{"id":31100950,"url":"https://github.com/mdlayher/wireguard_exporter","last_synced_at":"2025-09-16T23:05:08.650Z","repository":{"id":40414499,"uuid":"187677863","full_name":"mdlayher/wireguard_exporter","owner":"mdlayher","description":"Command wireguard_exporter implements a Prometheus exporter for WireGuard devices. MIT Licensed.","archived":true,"fork":false,"pushed_at":"2023-11-25T14:12:16.000Z","size":138,"stargazers_count":123,"open_issues_count":13,"forks_count":26,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-08-15T00:14:24.251Z","etag":null,"topics":["go","golang","networking","prometheus","vpn","wireguard"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mdlayher.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2019-05-20T16:35:23.000Z","updated_at":"2025-08-06T14:10:15.000Z","dependencies_parsed_at":"2023-11-25T15:24:23.693Z","dependency_job_id":"ae7e605b-aa3e-404f-be3a-4dbca8339f53","html_url":"https://github.com/mdlayher/wireguard_exporter","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/mdlayher/wireguard_exporter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mdlayher%2Fwireguard_exporter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mdlayher%2Fwireguard_exporter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mdlayher%2Fwireguard_exporter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mdlayher%2Fwireguard_exporter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mdlayher","download_url":"https://codeload.github.com/mdlayher/wireguard_exporter/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mdlayher%2Fwireguard_exporter/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":275500943,"owners_count":25476187,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-16T02:00:10.229Z","response_time":65,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["go","golang","networking","prometheus","vpn","wireguard"],"created_at":"2025-09-16T23:03:39.773Z","updated_at":"2025-09-16T23:05:08.627Z","avatar_url":"https://github.com/mdlayher.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# wireguard_exporter [![builds.sr.ht status](https://builds.sr.ht/~mdlayher/wireguard_exporter.svg)](https://builds.sr.ht/~mdlayher/wireguard_exporter?) [![GoDoc](https://godoc.org/github.com/mdlayher/wireguard_exporter?status.svg)](https://godoc.org/github.com/mdlayher/wireguard_exporter) [![Go Report Card](https://goreportcard.com/badge/github.com/mdlayher/wireguard_exporter)](https://goreportcard.com/report/github.com/mdlayher/wireguard_exporter)\n\nCommand `wireguard_exporter` implements a Prometheus exporter for WireGuard\ndevices. MIT Licensed.\n\n## Usage\n\nUse the `-h` flag to see full usage:\n\n```text\n$ wireguard_exporter -h\nUsage of wireguard_exporter:\n  -metrics.addr string\n        address for WireGuard exporter (default \":9586\")\n  -metrics.path string\n        URL path for surfacing collected metrics (default \"/metrics\")\n  -wireguard.peer-file string\n        optional: path to TOML friendly peer names mapping file; takes priority over -wireguard.peer-names\n  -wireguard.peer-names string\n        optional: comma-separated list of colon-separated public keys and friendly peer names, such as: \"keyA:foo,keyB:bar\"\n```\n\nFor simple deployments, specifying peer name mappings on the command line may\nbe sufficient:\n\n```text\n$ wireguard_exporter -wireguard.peer-names VWRsPtbdGtcNyaQ+cFAZfZnYL05uj+XINQS6yQY5gQ8=:foo\n```\n\nFor larger deployments, you can also specify a TOML file of friendly peer name\nmappings, which will supersede any command line flag mappings.\n\n```toml\n[[peer]]\npublic_key = \"VWRsPtbdGtcNyaQ+cFAZfZnYL05uj+XINQS6yQY5gQ8=\"\nname = \"foo\"\n\n[[peer]]\npublic_key = \"UvwWyMQ1ckLEG82Qdooyr0UzJhqOlzzcx90DXuwMTDA=\"\nname = \"bar\"\n```\n\n```text\n$ wireguard_exporter -wireguard.peer-file /etc/wireguard/peers.toml\n```\n\n## Example\n\nThis exporter exposes metrics about each configured WireGuard device and its\npeers, using any device implementation supported by [wgctrl-go](https://github.com/WireGuard/wgctrl-go).\n\n```text\n$ curl -s http://localhost:9586/metrics | grep wireguard\n# HELP wireguard_device_info Metadata about a device.\n# TYPE wireguard_device_info gauge\nwireguard_device_info{device=\"wg0\",public_key=\"QwAmAD1v4wMIX/0gKJbr9hv1o3YX0YTk7Mdj0L4dylI=\"} 1\n# HELP wireguard_peer_allowed_ips_info Metadata about each of a peer's allowed IP subnets for a given device.\n# TYPE wireguard_peer_allowed_ips_info gauge\nwireguard_peer_allowed_ips_info{allowed_ips=\"192.168.20.0/24\",device=\"wg0\",family=\"IPv4\",public_key=\"UvwWyMQ1ckLEG82Qdooyr0UzJhqOlzzcx90DXuwMTDA=\"} 1\nwireguard_peer_allowed_ips_info{allowed_ips=\"fd9e:1a04:f01d:20::/64\",device=\"wg0\",family=\"IPv6\",public_key=\"UvwWyMQ1ckLEG82Qdooyr0UzJhqOlzzcx90DXuwMTDA=\"} 1\n# HELP wireguard_peer_info Metadata about a peer. The public_key label on peer metrics refers to the peer's public key; not the device's public key.\n# TYPE wireguard_peer_info gauge\nwireguard_peer_info{device=\"wg0\",endpoint=\"\",name=\"foo\",public_key=\"VWRsPtbdGtcNyaQ+cFAZfZnYL05uj+XINQS6yQY5gQ8=\"} 1\nwireguard_peer_info{device=\"wg0\",endpoint=\"[fd9e:1a04:f01d:20:e5c2:7b69:90d8:ca45]:49203\",name=\"bar\",public_key=\"UvwWyMQ1ckLEG82Qdooyr0UzJhqOlzzcx90DXuwMTDA=\"} 1\n# HELP wireguard_peer_last_handshake_seconds UNIX timestamp for the last handshake with a given peer.\n# TYPE wireguard_peer_last_handshake_seconds gauge\nwireguard_peer_last_handshake_seconds{device=\"wg0\",public_key=\"UvwWyMQ1ckLEG82Qdooyr0UzJhqOlzzcx90DXuwMTDA=\"} 1.588274629e+09\nwireguard_peer_last_handshake_seconds{device=\"wg0\",public_key=\"VWRsPtbdGtcNyaQ+cFAZfZnYL05uj+XINQS6yQY5gQ8=\"} 0\n# HELP wireguard_peer_receive_bytes_total Number of bytes received from a given peer.\n# TYPE wireguard_peer_receive_bytes_total counter\nwireguard_peer_receive_bytes_total{device=\"wg0\",public_key=\"UvwWyMQ1ckLEG82Qdooyr0UzJhqOlzzcx90DXuwMTDA=\"} 76728\nwireguard_peer_receive_bytes_total{device=\"wg0\",public_key=\"VWRsPtbdGtcNyaQ+cFAZfZnYL05uj+XINQS6yQY5gQ8=\"} 0\n# HELP wireguard_peer_transmit_bytes_total Number of bytes transmitted to a given peer.\n# TYPE wireguard_peer_transmit_bytes_total counter\nwireguard_peer_transmit_bytes_total{device=\"wg0\",public_key=\"UvwWyMQ1ckLEG82Qdooyr0UzJhqOlzzcx90DXuwMTDA=\"} 76200\nwireguard_peer_transmit_bytes_total{device=\"wg0\",public_key=\"VWRsPtbdGtcNyaQ+cFAZfZnYL05uj+XINQS6yQY5gQ8=\"} 0\n```\n\n### Sample queries\n\nGet the receive and transmit rates and last handshake of individual peers, and enable querying on\nboth the WireGuard device name and the peer's friendly name:\n\n```\nirate(wireguard_peer_receive_bytes_total[5m]) * on (public_key, device) group_left(name) wireguard_peer_info * on (instance) group_left(device) wireguard_device_info\n```\n```\nirate(wireguard_peer_transmit_bytes_total[5m]) * on (public_key, device) group_left(name) wireguard_peer_info * on (instance) group_left(device) wireguard_device_info\n```\n```\ntime()-(wireguard_peer_last_handshake_seconds * on (public_key, device) group_left(name) wireguard_peer_info * on (instance) group_left(device) wireguard_device_info)\n```\n\n## Grafana Dashboard\n\nYou can view your data using this [Grafana Dashboard](https://grafana.com/grafana/dashboards/12177) using Prometheus as source.\n\n![Grafana Dashboard](grafana_wireguard.png)\n\n## Build Binary \n\n```\ncd cmd/wireguard_exporter/\ngo build .\nmv wireguard_exporter /usr/local/bin/\n```\n\n## Add service file for systemd\n\n```\n[Unit]\nDescription=Prometheus WireGuard Exporter\nAfter=network.target\n\n[Service]\nType=simple\nRestart=always\nExecStart=/usr/local/bin/wireguard_exporter\n\n[Install]\nWantedBy=multi-user.target\n```\n\nLoad new service and enable autostart:\n\n```\nsystemctl daemon-reload\nsystemctl enable wireguard-exporter.service\n```\n\n## Add scraping config to prometheus\n\nIn `/etc/prometheus/prometheus.yml` add following config to the section `scrape_configs:` :\n\n```\n  - job_name: wireguard\n    static_configs:\n      - targets: ['localhost:9586']\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmdlayher%2Fwireguard_exporter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmdlayher%2Fwireguard_exporter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmdlayher%2Fwireguard_exporter/lists"}