Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

friendly_name and friendly_json not working properly #112

Open
finnje opened this issue Apr 4, 2023 · 1 comment
Open

friendly_name and friendly_json not working properly #112

finnje opened this issue Apr 4, 2023 · 1 comment

Comments

@finnje
Copy link

finnje commented Apr 4, 2023

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:

  • I've used both friendly_name and friendly_json interchangeably and it does dynamically change on the working peer but has no affect on the other peers.
  • I've tried changing the order of the peers in the config with no change in outcome.
  • I've tried this in ubuntu 22.04 and NONE of the peers friendly_name appeared.
  • I've run the exporter in debug mode and see no errors or warnings
  • I've purposely used bad syntax in the friendly_json and found that if I do that on the working peer I get a warning in the exporter log
[2023-04-04T21:24:37Z WARN  prometheus_exporter_base] internal server error == FriendlyDescritionParseError(SerdeJsonError(Error("expected `:`", line: 1, column: 13)))
  • If I use bad syntax on a non-working peer no warning is thrown which leads me to believe it's not reading those peers for some reason.

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

@Jodu555
Copy link

Jodu555 commented Aug 14, 2023

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants