MindFlavor / prometheus_wireguard_exporter

A Prometheus exporter for WireGuard, written in Rust.
https://mindflavor.github.io/prometheus_wireguard_exporter
MIT License
463 stars 49 forks source link

No Friendly Name scraped #87

Closed MrDrache333 closed 2 years ago

MrDrache333 commented 2 years ago

No friendly Names are shown in the scraped metrics but configured as described in the ReadMe. Ive also restarted the service and Docker-Container

Docker-compose:

version: '3'
services:
  exporter:
    image: mindflavor/prometheus-wireguard-exporter:3.5.1
    restart: always
    network_mode: "host"
    volumes:
      - /etc/wireguard/wg0.conf:/etc/wireguard/wg0.conf
    cap_add:
      - NET_ADMIN

wg0.conf (1 client)

### begin keno ###
[Peer]
# friendly_name = Kenos iPhone
PublicKey = something
PresharedKey = something
AllowedIPs = 10.6.0.2/32
### end keno ###

Metrics:

# HELP wireguard_sent_bytes_total Bytes sent to the peer
# TYPE wireguard_sent_bytes_total counter
wireguard_sent_bytes_total{interface="wg0",public_key="something",allowed_ips="10.6.0.2/32"} 449223260

# HELP wireguard_received_bytes_total Bytes received from the peer
# TYPE wireguard_received_bytes_total counter
wireguard_received_bytes_total{interface="wg0",public_key="something",allowed_ips="10.6.0.2/32"} 76705376

# HELP wireguard_latest_handshake_seconds Seconds from the last handshake
# TYPE wireguard_latest_handshake_seconds gauge
wireguard_latest_handshake_seconds{interface="wg0",public_key="something",allowed_ips="10.6.0.2/32"} 1643142935
ncabete commented 2 years ago

I'm also experiencing the same but it's just for some clients. 2/15 clients haven't had their friendly_name scraped for some reason.

Lennys26 commented 2 years ago

The notes indicate "all you need to do is to add the friendly name in the comments preceding a peer (and enable the flag since this feature is opt-in)", but what/where is the flag?

ncabete commented 2 years ago

The notes indicate "all you need to do is to add the friendly name in the comments preceding a peer (and enable the flag since this feature is opt-in)", but what/where is the flag?

https://github.com/MindFlavor/prometheus_wireguard_exporter#flags-available

_PROMETHEUS_WIREGUARD_EXPORTER_CONFIG_FILENAMES or -n depending on what you use.

MindFlavor commented 2 years ago

@ncabete can you please start the explorer with the verbose flag active, try a scrape and post the log here? Be aware that, unless compiled with rust's leaky_log compile time flag, no private keys will be displayed but public keys will (if it bothers you, please redact them).

MindFlavor commented 2 years ago

Also note that if you have peers in the main wireguard file you have to specify it manually in the --extract_names_config_files file (it's not automatically parsed).

ncabete commented 2 years ago

@MindFlavor turns out I just had to clean up my peers config. Everything is working as intended on my side. Thank you