WireGuard
Plugin: go.d.plugin Module: wireguard
Overview
Monitor WireGuard VPN interfaces and their peers: traffic, peer counts, and the time since each peer's latest handshake.
Reads the state of the local WireGuard interfaces once per collection interval through the WireGuard control API, using the wgctrl library:
- On Linux, kernel WireGuard interfaces are read over netlink.
- Userspace implementations, such as wireguard-go and BoringTun, are read through their control sockets in
/var/run/wireguard.
The collector only reads interface and peer state; it never changes the WireGuard configuration.
This collector is supported on all platforms.
This collector only supports collecting metrics from a single instance of this integration.
Reading kernel WireGuard interfaces on Linux requires the CAP_NET_ADMIN capability. Standard installations grant it to go.d.plugin automatically; a containerized Agent needs it added to the container (see Prerequisites).
Default Behavior
Auto-Detection
The stock configuration runs one wireguard job that reads every WireGuard interface on the host. If the host has no WireGuard interface when the job starts, the job does not start; set autodetection_retry to keep checking for interfaces that come up later.
Limits
- Only interfaces in the Agent's network namespace are visible. WireGuard running inside a container with its own network, such as a containerized VPN server, is not collected.
- If any interface cannot be read, the whole collection fails and every WireGuard chart has a gap for that interval.
Performance Impact
The default configuration for this integration is not expected to impose a significant performance impact on the system.
Setup
You can configure the wireguard collector in two ways:
| Method | Best for | How to |
|---|---|---|
| UI | Fast setup without editing files | Go to Nodes → Configure this node → Collectors → Jobs, search for wireguard, then click + to add a job. |
| File | If you prefer configuring via file, or need to automate deployments (e.g., with Ansible) | Edit go.d/wireguard.conf and add a job. |
UI configuration requires paid Netdata Cloud plan.
Prerequisites
Add NET_ADMIN to a containerized Agent
Applies only to Agents running in a container. Reading kernel WireGuard interfaces needs the host network, which the documented docker run and Compose examples already use (--network=host), and the NET_ADMIN capability, which they do not add. Add it to the container:
--cap-add NET_ADMIN
With Docker Compose, add NET_ADMIN to the service's cap_add list.
Configuration
Options
The following options can be defined globally: update_every, autodetection_retry.
| Option | Description | Default | Required |
|---|---|---|---|
| update_every | Data collection interval, in seconds. | 1 | no |
| autodetection_retry | How often to retry the initial connection when the job fails to start, in seconds. Zero disables retries. | 0 | no |
via UI
Configure the wireguard collector from the Netdata web interface:
- Go to Nodes.
- Select the node where you want the wireguard data-collection job to run and click the ⚙ (Configure this node). That node will run the data collection.
- The Collectors → Jobs view opens by default.
- In the Search box, type wireguard (or scroll the list) to locate the wireguard collector.
- Click the + next to the wireguard collector to add a new job.
- Fill in the job fields, then click Test to verify the configuration and Submit to save.
- Test validates the provided settings and checks the collector's startup prerequisites. Successful validation does not guarantee that every metric will be available during collection.
- If it fails, an error message appears with details (for example, connection refused, timeout, or command execution errors), so you can adjust and retest.
via File
The configuration file name for this integration is go.d/wireguard.conf.
The file format is YAML. Generally, the structure is:
update_every: 1
autodetection_retry: 0
jobs:
- name: some_name1
- name: some_name2
You can edit the configuration file using the edit-config script from the
Netdata config directory.
cd /etc/netdata 2>/dev/null || cd /opt/netdata/etc/netdata
sudo ./edit-config go.d/wireguard.conf
Examples
Basic
The stock configuration. One job reads every WireGuard interface on the host.
Config
jobs:
- name: wireguard
WireGuard starts after Netdata
Keeps retrying every 60 seconds while the host has no WireGuard interface, so the job starts once the VPN comes up.
Config
jobs:
- name: wireguard
autodetection_retry: 60
Alerts
There are no alerts configured by default for this integration.
Metrics
Metrics grouped by scope.
The scope defines the instance that the metric belongs to. An instance is uniquely identified by a set of labels.
Peers that have never completed a handshake count toward the interface's peer total, but have no per-peer charts and add nothing to the interface traffic. An interface whose peers have not completed any handshake has no traffic chart until the first one does.
Per device
A WireGuard network interface on the host.
Labels:
| Label | Description |
|---|---|
| device | WireGuard interface name, for example wg0. |
Metrics:
| Metric | Description | Dimensions | Unit |
|---|---|---|---|
| wireguard.device_network_io | Device traffic | receive, transmit | B/s |
| wireguard.device_peers | Device peers | peers | peers |
Per peer
A peer configured on a WireGuard interface. Appears after the peer's first handshake.
Labels:
| Label | Description |
|---|---|
| device | WireGuard interface name, for example wg0. |
| public_key | The peer's public key, base64-encoded. |
Metrics:
| Metric | Description | Dimensions | Unit |
|---|---|---|---|
| wireguard.peer_network_io | Peer traffic | receive, transmit | B/s |
| wireguard.peer_latest_handshake_ago | Peer time elapsed since the latest handshake | time | seconds |
Troubleshooting
Diagnostics
Debug Mode
Important: Debug mode is not supported for data collection jobs created via the UI using the Dyncfg feature.
To troubleshoot issues with the wireguard collector, run the go.d.plugin with the debug option enabled. The output
should give you clues as to why the collector isn't working.
-
Navigate to the
plugins.ddirectory, usually at/usr/libexec/netdata/plugins.d/. If that's not the case on your system, opennetdata.confand look for thepluginssetting under[directories].cd /usr/libexec/netdata/plugins.d/ -
Switch to the
netdatauser.sudo -u netdata -s -
Run the
go.d.pluginto debug the collector:./go.d.plugin -d -m wireguardTo debug a specific job:
./go.d.plugin -d -m wireguard -j jobName
Getting Logs
If you're encountering problems with the wireguard collector, follow these steps to retrieve logs and identify potential issues:
- Run the command specific to your system (systemd, non-systemd, or Docker container).
- Examine the output for any warnings or error messages that might indicate issues. These messages should provide clues about the root cause of the problem.
System with systemd
Use the following command to view logs generated since the last Netdata service restart:
journalctl _SYSTEMD_INVOCATION_ID="$(systemctl show --value --property=InvocationID netdata)" --namespace=netdata --grep wireguard
System without systemd
Locate the collector log file, typically at /var/log/netdata/collector.log, and use grep to filter for collector's name:
grep wireguard /var/log/netdata/collector.log
Note: This method shows logs from all restarts. Focus on the latest entries for troubleshooting current issues.
Docker Container
If your Netdata runs in a Docker container named "netdata" (replace if different), use this command:
docker logs netdata 2>&1 | grep wireguard
Known Errors
no WireGuard devices found
Cause
The job found no WireGuard interface in the Agent's network namespace when it started, so it did not start. This happens when the VPN comes up after Netdata, or when WireGuard runs in a container with its own network.
Fix
Set autodetection_retry so the job starts on its own once an interface appears (see the "WireGuard starts after Netdata" example), or restart Netdata after bringing the interface up. WireGuard inside a container with its own network cannot be collected.
retrieving WireGuard devices: operation not permitted
Cause
go.d.plugin lacks the CAP_NET_ADMIN capability needed to read kernel WireGuard interfaces. Usually the Agent runs in a container started without NET_ADMIN, or a hardened install dropped the plugin's file capabilities.
Fix
In a container, add NET_ADMIN as described in Prerequisites. Otherwise re-run the Netdata installer, which restores the plugin's file capabilities.
Do you have any feedback for this page? If so, you can open a new issue on our netdata/learn repository.