Closed sebasdt closed 1 year ago
+1 I'm having the same issue. I used 3.6.1 because of: https://github.com/MindFlavor/prometheus_wireguard_exporter/issues/99
Okay @jano477 I have found a work-around and that is this:
In the docks at the bottom there they say you need to add -a true -v true
at the end of the docker command after the image.
Like this: sudo docker run -d --net=host --cap-add=NET_ADMIN --name wgexporter mindflavor/prometheus-wireguard-exporter -v true -a true
doing this should make it work atleast for me. Its kinda fixed for now but not out of the box!
Okay, I see. It works when I run it via docker run
like docker run -d --volume /etc/wireguard/wg0.conf:/etc/wireguard/wg0.conf --net=host --cap-add=NET_ADMIN --name wg-exporter mindflavor/prometheus-wireguard-exporter -n /etc/wireguard/wg0.conf -i wg0 -v true -a true
I couldn't get it working via compose-file and still don't know why.
wg-exporter:
image: mindflavor/prometheus-wireguard-exporter
container_name: wg-exporter
volumes:
- /etc/wireguard/:/etc/wireguard/:ro
environment:
- PROMETHEUS_WIREGUARD_EXPORTER_PORT=9587
- PROMETHEUS_WIREGUARD_EXPORTER_INTERFACES=wg0
- PROMETHEUS_WIREGUARD_EXPORTER_EXPORT_REMOTE_IP_AND_PORT_ENABLED=true
- PROMETHEUS_WIREGUARD_EXPORTER_CONFIG_FILE_NAMES=/etc/wireguard/wg0.conf
- EXPORT_LATEST_HANDSHAKE_DELAY=true
network_mode: host
cap_add:
- NET_ADMIN
command: -v true -a true
That one results not exporting any metrics. When I exec into the container I can see the wg-command is not working due to permission problems on wg0. It doesn't change when the container runs privileged.
docker exec -it wg-exporter /bin/sh
/usr/local/bin $ wg
Unable to access interface wg0: Operation not permitted
docker logs wg-exporter
[2023-02-25T18:39:20Z INFO prometheus_wireguard_exporter] prometheus_wireguard_exporter v3.6.6 starting...
[2023-02-25T18:39:20Z INFO prometheus_wireguard_exporter] using options: Options { verbose: true, prepend_sudo: true, separate_allowed_ips: false, extract_names_config_files: Some(["/etc/wireguard/wg0.conf"]), interfaces: Some(["wg0"]), export_remote_ip_and_port: true, export_latest_handshake_delay: true }
[2023-02-25T18:39:20Z INFO prometheus_wireguard_exporter] starting exporter on http://0.0.0.0:9587/metrics
[2023-02-25T18:39:20Z INFO prometheus_exporter_base] Listening on http://0.0.0.0:9587/metrics
But after several minutes the container suddenly starts to export metrics despite the permission problem persists.
Also dont forget --restart unless-stopped
variable somehow the container stops randomly without an logs.
Temporary fix: Add -a true -v true at the end of the docker command after the docker image. Now it should work and scrape data. The command should look like something like this: sudo docker run -d --net=host --cap-add=NET_ADMIN --restart unless-stopped --name wgexporter mindflavor/prometheus-wireguard-exporter -v true -a true
This has worked like a charm for me and fixed the issue. Closing the issue.
Hi, At the end of this comment there is a temporally fix that worked for me
I just stumbled into this awesome project.
My setup: Ive got a single node setup with proxmox and 3 lxc containers for testing. All of the containers are installed using proxmox helper scripts container 1: is the prometheus container 2: is the wireguard with exporter container 3: grafana for dashboards. Everything is set to default and no ports are changed or firewalls enabled. The wireguard vpn has 2 clients both of em can connect and use the internet.
What works: Prometheus is able to talk to the wireguard exporter and is trying to collect data. I used this command to get the container to start:
sudo docker run -d -p 9586:9586 -it mindflavor/prometheus-wireguard-exporter -v true
The issue: Im running into the following issue where prometheus is scraping data from the exporter but nothing is recieved back. While looking at the container logs withdocker logs --since=1h pensive_jepsen
returns this:Directly dumping the wireguard data with
sudo wg show all dump
shows it can export data.Then my next step was to test if exporter collects anything with
curl -s http://127.0.0.1:9586/metrics
on the host machine.Possible cause of the Issue: It all seems like the exporter isnt able to collect data so I came up with these theories:
If you need more information about anything related feel free to ask. Im all new to prometheus and want to learnt the basics.
Temporary fix: Add
-a true -v true
at the end of the docker command after the docker image. Now it should work and scrape data. The command should look like something like this:sudo docker run -d --net=host --cap-add=NET_ADMIN --restart unless-stopped --name wgexporter mindflavor/prometheus-wireguard-exporter -v true -a true