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

friendly_name and friendly_json not working properly #112

Open finnje opened 1 year ago

finnje commented 1 year ago

Summary

I've installed prometheus_wireguard_exporter via cargo (version 3.6.6) on ubuntu 22.04 and added friendly_name and friendly_json to the wireguard configs but they are not showing up in the metrics properly. Only one peer shows up.

Expected outcome

The friendly_name and friendly_json key value pairs should show up in the metrics for all peers where they are defined.

Exporter Version

# prometheus_wireguard_exporter --version
prometheus_wireguard_exporter 3.6.6

Wireguard Peer Config

[Peer]
# friendly_json={"peer_name":"vm02"}
PublicKey = 7LetcwPem8vGgLCx71lQkeivvm9FVPtkeVAc3BTEvXg=
Endpoint = 10.10.10.11:51818
AllowedIps = 10.254.254.2/32
PersistentKeepalive = 25

[Peer]
# friendly_json={"peer_name":"vm03"}
PublicKey = 7jpY/7C+A/rYMEzHi1qNqmUSJKZK+gp68WUNThqY+FQ=
Endpoint = 10.10.10.12:51818
AllowedIps = 10.254.254.3/32
PersistentKeepalive = 25

[Peer]
# friendly_json={"peer_name":"vm04"}
PublicKey = qz27h6YxDV7IpGFvEK77QjCr6e06iQvaFqFdZsOQZ3o=
Endpoint = 10.10.10.13:51818
AllowedIps = 10.254.254.4/32

Exporter Startup

# prometheus_wireguard_exporter -n /etc/wireguard/wg0.conf
[2023-04-04T19:08:45Z INFO  prometheus_wireguard_exporter] prometheus_wireguard_exporter v3.6.6 starting...
[2023-04-04T19:08:45Z INFO  prometheus_wireguard_exporter] using options: Options { verbose: false, prepend_sudo: false, separate_allowed_ips: false, extract_names_config_files: Some(["/etc/wireguard/wg0.conf"]), interfaces: None, export_remote_ip_and_port: false, export_latest_handshake_delay: false }
[2023-04-04T19:08:45Z INFO  prometheus_wireguard_exporter] starting exporter on http://0.0.0.0:9586/metrics
[2023-04-04T19:08:45Z INFO  prometheus_exporter_base] Listening on http://0.0.0.0:9586/metrics

Metrics Output

# HELP wireguard_sent_bytes_total Bytes sent to the peer
# TYPE wireguard_sent_bytes_total counter
wireguard_sent_bytes_total{interface="wg0",public_key="7LetcwPem8vGgLCx71lQkeivvm9FVPtkeVAc3BTEvXg=",allowed_ips="10.254.254.2/32"} 1476
wireguard_sent_bytes_total{interface="wg0",public_key="7jpY/7C+A/rYMEzHi1qNqmUSJKZK+gp68WUNThqY+FQ=",allowed_ips="10.254.254.3/32",peer_name="vm03"} 1604
wireguard_sent_bytes_total{interface="wg0",public_key="qz27h6YxDV7IpGFvEK77QjCr6e06iQvaFqFdZsOQZ3o=",allowed_ips="10.254.254.4/32"} 1956

# HELP wireguard_received_bytes_total Bytes received from the peer
# TYPE wireguard_received_bytes_total counter
wireguard_received_bytes_total{interface="wg0",public_key="7LetcwPem8vGgLCx71lQkeivvm9FVPtkeVAc3BTEvXg=",allowed_ips="10.254.254.2/32"} 1068
wireguard_received_bytes_total{interface="wg0",public_key="7jpY/7C+A/rYMEzHi1qNqmUSJKZK+gp68WUNThqY+FQ=",allowed_ips="10.254.254.3/32",peer_name="vm03"} 1164
wireguard_received_bytes_total{interface="wg0",public_key="qz27h6YxDV7IpGFvEK77QjCr6e06iQvaFqFdZsOQZ3o=",allowed_ips="10.254.254.4/32"} 972

# HELP wireguard_latest_handshake_seconds UNIX timestamp seconds of the last handshake
# TYPE wireguard_latest_handshake_seconds gauge
wireguard_latest_handshake_seconds{interface="wg0",public_key="7LetcwPem8vGgLCx71lQkeivvm9FVPtkeVAc3BTEvXg=",allowed_ips="10.254.254.2/32"} 1680643129
wireguard_latest_handshake_seconds{interface="wg0",public_key="7jpY/7C+A/rYMEzHi1qNqmUSJKZK+gp68WUNThqY+FQ=",allowed_ips="10.254.254.3/32",peer_name="vm03"} 1680643062
wireguard_latest_handshake_seconds{interface="wg0",public_key="qz27h6YxDV7IpGFvEK77QjCr6e06iQvaFqFdZsOQZ3o=",allowed_ips="10.254.254.4/32"} 1680643133

Troubleshooting

I've tried:

FYI, there is a typo in the above warning line. I believe it should be "Description" vs "Descrition"

Jodu555 commented 10 months ago

I've used the docker version and it works fine for me! Maybe give Docker a try although I kinda have both variants you mentioned!

[Peer]
# friendly_name = xxx
# friendly_json={"peer_name":"xxx"}
PublicKey = xxx
PresharedKey = xxx
AllowedIPs = 10.7.0.2/32

At this point, I don't really know which of them works and I'm too scared to touch it!