Prometheus WireGuard Exporter

legal

Crate cratedown cratelastdown

tag release commitssince

Intro

A Prometheus exporter for WireGuard, written in Rust. This tool exports the wg show all dump results in a format that Prometheus can understand. The exporter is very light on your server resources, both in terms of memory and CPU usage.

Prerequisites

Compilation

To compile the latest master version:

bash git clone https://github.com/MindFlavor/prometheus_wireguard_exporter.git cd prometheus_wireguard_exporter cargo install --path .

If you want the latest release you can simply use:

bash cargo install prometheus_wireguard_exporter

Usage

Start the binary with -h to get the complete syntax. The parameters are:

| Parameter | Mandatory | Valid values | Default | Description | | -- | -- | -- | -- | -- | | -v | no | | | Enable verbose mode. | -p | no | any valid port number | 9576 | Specify the service port. This is the port your Prometheus instance should point to.

Once started, the tool will listen on the specified port (or the default one, 9576, if not specified) and return a Prometheus valid response at the url /metrics. So to check if the tool is working properly simply browse the http://localhost:9576 (or whichever port you choose).

Systemd service file

Now add the exporter to the Prometheus exporters as usual. I recommend to start it as a service. It's necessary to run it as root (if there is a non-root way to call wg show all dump please let me know). My systemd service file is like this one:

``` [Unit] Description=Prometheus WireGuard Exporter Wants=network-online.target After=network-online.target

[Service] User=root Group=root Type=simple ExecStart=/usr/local/bin/prometheuswireguardexporter

[Install] WantedBy=multi-user.target ```