Skip to content

[SOLVED] friendly_* not exported with systemd-networkd wireguard confing #132

@gramanas

Description

@gramanas

Hello,

I can't get the friendly name exported in the metrics.

This is my systemd-networkd config:

cat /etc/systemd/network/99-wg0.netdev 
[NetDev]
Name=wg0
Kind=wireguard
Description=WireGuard tunnel wg0

[WireGuard]
ListenPort=xxxxx
PrivateKeyFile=...

[WireGuardPeer]
# friendly_name=mobile
# friendly_json={"peer_name":"mobile"}
PublicKeyFile=xxx
PresharedKeyFile=xxx
AllowedIPs=10.0.0.10/32

I run the exporter with:

WIREGUARD_EXPORTER_ARGS="-n /etc/systemd/network/99-wg0.netdev -a true -d true -r true -i wg0 -v true"

and in the debug output I can see the friendly tag just fine:

Mar 27 18:08:38 prometheus-wireguard-exporter[172198]: [2025-03-27T16:08:38Z TRACE prometheus_wireguard_exporter] peer_entry_hashmap == Some(
Mar 27 18:08:38 prometheus-wireguard-exporter[172198]:         {
Mar 27 18:08:38 prometheus-wireguard-exporter[172198]:             "/path/to/key.pub": PeerEntry {
Mar 27 18:08:38 prometheus-wireguard-exporter[172198]:                 public_key: "/path/to/key.pub",
Mar 27 18:08:38 prometheus-wireguard-exporter[172198]:                 allowed_ips: "10.0.0.10/32",
Mar 27 18:08:38 prometheus-wireguard-exporter[172198]:                 friendly_description: Some(
Mar 27 18:08:38 prometheus-wireguard-exporter[172198]:                     Json(
Mar 27 18:08:38 prometheus-wireguard-exporter[172198]:                         {
Mar 27 18:08:38 prometheus-wireguard-exporter[172198]:                             "peer_name": String("mobile"),
Mar 27 18:08:38 prometheus-wireguard-exporter[172198]:                         },
Mar 27 18:08:38 prometheus-wireguard-exporter[172198]:                     ),
Mar 27 18:08:38 prometheus-wireguard-exporter[172198]:                 ),
Mar 27 18:08:38 prometheus-wireguard-exporter[172198]:             },

but in the metrics there is no label added


So while I was writing this I pretty much realized what the problem is: the exporter uses the public_key read from the config to match against the public key exported from wg show dump and since I am using PublicKeyFile and the exporter doesn't attempt to read it, it fails to match and it just silently does not print the friendly tag while it does print the public key (just not the one read from the config file)

In any case the proper solution is to add the functionality on the peer definition upstream, I made it work for now buy using the raw key value instead of the key file in my peers

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions