Skip to content

Instantly share code, notes, and snippets.

@brandon1024
Last active July 29, 2026 20:10
Show Gist options
  • Select an option

  • Save brandon1024/3bb397ed98f445b06622aafe90c3a28d to your computer and use it in GitHub Desktop.

Select an option

Save brandon1024/3bb397ed98f445b06622aafe90c3a28d to your computer and use it in GitHub Desktop.
Wireguard Exporter [Node Exporter Textfile Collector]

A Simple Solution for Wireguard Interface and Peer Metrics Exposition to Prometheus

Here's a simple set of scripts that allow you to export wireguard tunnel statistics to a file in Prometheus text format. This file can be read by the node_exporter textfile collector, for example.

You might be asking, why does this exist? Why not MindFlavor/prometheus_wireguard_exporter? The reality is that a full-fledged webserver written in Rust to expose wireguard metrics is a bit overkill. I've accomplished the same thing in ~100 lines of (well documented) Awk. It's dead simple, and a no brainer if you're already using node-exporter.

For those conscious about security, you'll be happy to know the script itself does't run any wireguard commands; it doesn't even need to be run as root. It accepts a wg dump from stdin, and that's it. The metrics exposition is completely isolated from the wireguard configuration, unlike MindFlavor/prometheus_wireguard_exporter. No need to deal with docker containers attached to the host network, which is annoying when you're running mostly rootless containers.

Simplest Usage

If you want to dump prometheus metrics to stdout, try this:

# wg show all dump | wg-dump.awk

You'll get something like this:

# HELP node_network_wireguard_interface Wireguard network interface information.
# TYPE node_network_wireguard_interface gauge
node_network_wireguard_interface{device="wg0",public_key="wDArzrW4UnZ6Zfp7/zHvGNH0wx71yhEqOXTu6Jgfbgc=",port="51820",fwmark="off"} 1.0
# HELP node_network_wireguard_peer_handshake Latest handshake for a particular Wireguard peer.
# TYPE node_network_wireguard_peer_handshake gauge
node_network_wireguard_peer_handshake{device="wg0",public_key="Hav2lvmaicPSly4I25oEHcv8o4ycFNIzriADheeSFjY=",endpoint="192.168.3.8/32",persistent_keepalive="off"} 1677452335
node_network_wireguard_peer_handshake{device="wg0",public_key="ypLMnc92ZUDNMSuEUtW0Nh5VWFooxXXWYcaZx8zLU2c=",endpoint="192.168.3.14/32",persistent_keepalive="off"} 1677208600
node_network_wireguard_peer_handshake{device="wg0",public_key="JAJ264l63wILq02WmcWDwFuLAUPhI8XTweRc/Wgxw2M=",endpoint="192.168.3.5/32",persistent_keepalive="off"} 1677452428
...

Exposing Metrics to Prometheus

If you want to use this script to expose wireguard metrics to Prometheus:

  • enable the prometheus textfile collector (e.g. --collector.textfile.directory=/var/run/prometheus)
  • create a systemd timer or cron that runs the script on a interval
# cp prometheus-collect-wg.timer /etc/systemd/system/
# cp prometheus-collect-wg.service /etc/systemd/system/
# systemctl enable prometheus-collect-wg.timer
# systemctl enable prometheus-collect-wg.service
# systemctl start prometheus-collect-wg.timer

Mapping Public Keys to Human Friendly Names

Public keys aren't all that useful for us mortals. Mapping these keys to human-friendly names is easy (and no it does not involve vanity keys). Simply create a key map file and provide the path to the file as an environment variable.

The key map file is a tab-separated file where each line in the file maps a public key to it's human-friendly name.

Zo0Z5MClSQZsWlG3hS9RgoE6kHQHWYhGJ3i9DuB1yV4=    Home Server
fvEBlU5mZGelXse9copyYt/c75H9XfQeVMFGVItJu1Q=    Phone
wDArzrW4UnZ6Zfp7/zHvGNH0wx71yhEqOXTu6Jgfbgc=    Personal Laptop
pQNmjK+YF7/OLTYCon/rUf707gD29SHuKvhxM6f93Eg=    Friend

Building a Grafana Dashboard

Once set up, create some visualization for the health and statistics of your Wireguard network in Grafana. You can import the dashboard shown below from the JSON model wg-grafana-dashboard.json.

image

[Unit]
Description=Wireguard Prometheus Exporter
[Service]
Type=oneshot
LogLevelMax=warning
SyslogLevel=warning
RuntimeDirectory=prometheus
RuntimeDirectoryPreserve=yes
ExecStart=/bin/sh -c 'wg show all dump | awk -v keymap_file=/etc/wireguard/peer-key-ids.conf -f /usr/local/bin/wg-dump.awk >${RUNTIME_DIRECTORY}/wireguard.prom.tmp'
ExecStart=/usr/bin/mv ${RUNTIME_DIRECTORY}/wireguard.prom.tmp ${RUNTIME_DIRECTORY}/wireguard.prom
[Install]
WantedBy=default.target
[Unit]
Description=Export Wireguard metrics to a file for consumption by node exporter textfile collector.
[Timer]
OnBootSec=30
OnUnitActiveSec=15
[Install]
WantedBy=timers.target
#!/usr/bin/awk -f
#
# wg-dump - pick apart wireguard tunnel information and print in prometheus line format
#
# Accepts input from `wg show all dump` and transforms into metrics in prometheus line format
# to stdout. Human-friendly names can be assigned to peers by providing a key map file.
#
# # Key Map File Format & Configuration
#
# To configure a key map file, set the keymap_file variable with the path to the file. The
# file must be tab-separated, the first field being the public key and the second field
# being an arbitrary name for the key.
#
# # Usage
#
# $ wg show all dump | wg-dump.awk
# $ wg show all dump | awk -v keymap_file=keymap.conf -f wg-dump.awk
BEGIN {
# if a key id map is configured, use it to provide human-friendly names for keys
if (keymap_file) {
FS = "\t"
while ((getline < keymap_file) > 0) {
keymap[$1] = $2
}
close(keymap_file)
}
FS = " "
ERR = 0
}
# Lookup the human-friendly name for a key, returning the original key if no name exists.
function public_key_to_name(key) {
if (key in keymap) {
return keymap[key]
}
return key
}
# Create metrics for an interface.
function interface(dev, pubkey, port, fwmark) {
name = public_key_to_name(pubkey)
labels = "device=\"" dev "\",public_key=\"" pubkey "\",port=\"" port "\",fwmark=\"" fwmark "\",name=\"" name "\""
wireguard_iface["node_network_wireguard_interface{" labels "}"] = "1.0"
# this interface is a single node in the graph
labels = "type=\"node\",id=\"" pubkey "\",title=\"" name "\",detail__public_key=\"" pubkey "\",mainstat=\"" dev "\",secondarystat=\"" port "\""
wireguard_node_graph["node_network_wireguard_node_graph{" labels "}"] = "1.0"
}
# Register metrics for a peer.
function peer(dev, iface_pubkey, pubkey, pre_shared_key, endpoint, allowed_ips, last_handshake, transfer_rx, transfer_tx, persistent_keepalive) {
name = public_key_to_name(pubkey)
labels = "device=\"" dev "\",public_key=\"" pubkey "\",endpoint=\"" allowed_ips "\",persistent_keepalive=\"" persistent_keepalive "\",name=\"" name "\""
wireguard_peer_handshake["node_network_wireguard_peer_handshake{" labels "}"] = last_handshake
wireguard_peer_tx["node_network_wireguard_peer_tx{" labels "}"] = transfer_tx
wireguard_peer_rx["node_network_wireguard_peer_rx{" labels "}"] = transfer_rx
# this peer is a single node in the graph, but connected by an edge to the interface node
labels = "type=\"node\",id=\"" pubkey "\",title=\"" name "\",mainstat=\"" dev "\",secondarystat=\"" allowed_ips "\",detail__public_key=\"" pubkey "\""
wireguard_node_graph["node_network_wireguard_node_graph{" labels "}"] = "1.0"
labels = "type=\"edge\",id=\"" iface_pubkey pubkey "\",source=\"" iface_pubkey "\",target=\"" pubkey "\""
wireguard_node_graph["node_network_wireguard_node_graph{" labels "}"] = "1.0"
}
# Consume input from the dump and collect into maps.
{
if (NF == 5) {
# update metrics for interface
interface($1, $3, $4, $5)
# map devices to their public keys
interfaces[$1] = $3
} else if (NF == 9) {
# update metrics for peer
peer($1, interfaces[$1], $2, $3, $4, $5, $6, $7, $8, $9)
} else {
print "panic: unexpected number of fields in input; expected 5 or 9, was " NF
ERR = 1
exit
}
}
# Write Prometheus-style metrics to stdout.
END {
if (ERR) exit 1
print "# HELP node_network_wireguard_interface Wireguard network interface information."
print "# TYPE node_network_wireguard_interface gauge"
for (metric in wireguard_iface) {
print metric " " wireguard_iface[metric]
}
print "# HELP node_network_wireguard_peer_handshake Latest handshake for a particular Wireguard peer."
print "# TYPE node_network_wireguard_peer_handshake gauge"
for (metric in wireguard_peer_handshake) {
print metric " " wireguard_peer_handshake[metric]
}
print "# HELP node_network_wireguard_peer_tx Transmit statistics for a particular Wireguard peer."
print "# TYPE node_network_wireguard_peer_tx counter"
for (metric in wireguard_peer_tx) {
print metric " " wireguard_peer_tx[metric]
}
print "# HELP node_network_wireguard_peer_rx Receive statistics for a particular Wireguard peer."
print "# TYPE node_network_wireguard_peer_rx counter"
for (metric in wireguard_peer_rx) {
print metric " " wireguard_peer_rx[metric]
}
print "# HELP node_network_wireguard_node_graph Metrics useful for rendering a node graph representation of the network."
print "# TYPE node_network_wireguard_node_graph gauge"
for (metric in wireguard_node_graph) {
print metric " " wireguard_node_graph[metric]
}
}
{
"annotations": [
{
"kind": "AnnotationQuery",
"spec": {
"builtIn": true,
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations & Alerts",
"query": {
"datasource": {
"name": "-- Grafana --"
},
"group": "grafana",
"kind": "DataQuery",
"spec": {
"limit": 100,
"matchAny": false,
"tags": [],
"type": "dashboard"
},
"version": "v0"
}
}
}
],
"cursorSync": "Off",
"editable": true,
"elements": {
"panel-10": {
"kind": "Panel",
"spec": {
"data": {
"kind": "QueryGroup",
"spec": {
"queries": [
{
"kind": "PanelQuery",
"spec": {
"hidden": false,
"query": {
"datasource": {
"name": "s8uwo_x4k"
},
"group": "prometheus",
"kind": "DataQuery",
"spec": {
"editorMode": "code",
"exemplar": false,
"expr": "count(node_network_wireguard_peer_handshake{job=\"$job\",instance=\"$node\",device=\"$interface\"})",
"instant": true,
"legendFormat": "__auto",
"range": false
},
"version": "v0"
},
"refId": "A"
}
}
],
"queryOptions": {},
"transformations": []
}
},
"description": "",
"id": 10,
"links": [],
"title": "",
"transparent": true,
"vizConfig": {
"group": "stat",
"kind": "VizConfig",
"spec": {
"fieldConfig": {
"defaults": {
"color": {
"mode": "fixed"
},
"displayName": "Peers",
"noValue": "None",
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": 0
},
{
"color": "red",
"value": 80
}
]
}
},
"overrides": []
},
"options": {
"colorMode": "value",
"graphMode": "none",
"justifyMode": "auto",
"orientation": "auto",
"percentChangeColorMode": "standard",
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false
},
"showPercentChange": false,
"textMode": "value_and_name",
"wideLayout": true
}
},
"version": "13.1.0"
}
}
},
"panel-11": {
"kind": "Panel",
"spec": {
"data": {
"kind": "QueryGroup",
"spec": {
"queries": [
{
"kind": "PanelQuery",
"spec": {
"hidden": false,
"query": {
"datasource": {
"name": "s8uwo_x4k"
},
"group": "prometheus",
"kind": "DataQuery",
"spec": {
"editorMode": "code",
"exemplar": false,
"expr": "count((time() - node_network_wireguard_peer_handshake{job=\"$job\",instance=\"$node\",device=\"$interface\",name=~\"$peer\"}) <= 180) OR on() vector(0)",
"format": "time_series",
"instant": false,
"legendFormat": "__auto",
"range": true
},
"version": "v0"
},
"refId": "A"
}
}
],
"queryOptions": {},
"transformations": []
}
},
"description": "",
"id": 11,
"links": [],
"title": "",
"transparent": true,
"vizConfig": {
"group": "stat",
"kind": "VizConfig",
"spec": {
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"displayName": "Active Peers",
"min": 0,
"noValue": "None",
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": 0
},
{
"color": "red",
"value": 80
}
]
}
},
"overrides": []
},
"options": {
"colorMode": "value",
"graphMode": "area",
"justifyMode": "auto",
"orientation": "auto",
"percentChangeColorMode": "standard",
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false
},
"showPercentChange": false,
"textMode": "value_and_name",
"wideLayout": true
}
},
"version": "13.1.0"
}
}
},
"panel-12": {
"kind": "Panel",
"spec": {
"data": {
"kind": "QueryGroup",
"spec": {
"queries": [
{
"kind": "PanelQuery",
"spec": {
"hidden": false,
"query": {
"datasource": {
"name": "s8uwo_x4k"
},
"group": "prometheus",
"kind": "DataQuery",
"spec": {
"editorMode": "code",
"expr": "sum(node_network_wireguard_peer_tx{job=\"$job\",instance=\"$node\",device=\"$interface\",name=~\"$peer\"})",
"legendFormat": "__auto",
"range": true
},
"version": "v0"
},
"refId": "A"
}
}
],
"queryOptions": {},
"transformations": []
}
},
"description": "",
"id": 12,
"links": [],
"title": "",
"transparent": true,
"vizConfig": {
"group": "timeseries",
"kind": "VizConfig",
"spec": {
"fieldConfig": {
"defaults": {
"color": {
"fixedColor": "green",
"mode": "fixed"
},
"custom": {
"axisBorderShow": false,
"axisCenteredZero": false,
"axisColorMode": "text",
"axisLabel": "",
"axisPlacement": "auto",
"axisSoftMin": 0,
"barAlignment": 0,
"barWidthFactor": 0.6,
"drawStyle": "line",
"fillOpacity": 20,
"gradientMode": "opacity",
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"insertNulls": false,
"lineInterpolation": "linear",
"lineWidth": 1,
"pointSize": 5,
"scaleDistribution": {
"type": "linear"
},
"showPoints": "auto",
"showValues": false,
"spanNulls": false,
"stacking": {
"group": "A",
"mode": "none"
},
"thresholdsStyle": {
"mode": "off"
}
},
"displayName": "tx ↑",
"noValue": "None",
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": 0
}
]
},
"unit": "decbytes"
},
"overrides": []
},
"options": {
"annotations": {
"clustering": -1,
"multiLane": false
},
"legend": {
"calcs": [
"lastNotNull"
],
"displayMode": "list",
"enableFacetedFilter": false,
"overflow": "ellipsis",
"placement": "bottom",
"showLegend": true
},
"tooltip": {
"hideZeros": false,
"mode": "single",
"sort": "none"
}
}
},
"version": "13.1.0"
}
}
},
"panel-13": {
"kind": "Panel",
"spec": {
"data": {
"kind": "QueryGroup",
"spec": {
"queries": [
{
"kind": "PanelQuery",
"spec": {
"hidden": false,
"query": {
"datasource": {
"name": "s8uwo_x4k"
},
"group": "prometheus",
"kind": "DataQuery",
"spec": {
"editorMode": "code",
"expr": "sum(node_network_wireguard_peer_rx{job=\"$job\",instance=\"$node\",device=\"$interface\",name=~\"$peer\"})",
"legendFormat": "__auto",
"range": true
},
"version": "v0"
},
"refId": "A"
}
}
],
"queryOptions": {},
"transformations": []
}
},
"description": "",
"id": 13,
"links": [],
"title": "",
"transparent": true,
"vizConfig": {
"group": "timeseries",
"kind": "VizConfig",
"spec": {
"fieldConfig": {
"defaults": {
"color": {
"fixedColor": "blue",
"mode": "fixed"
},
"custom": {
"axisBorderShow": false,
"axisCenteredZero": false,
"axisColorMode": "text",
"axisLabel": "",
"axisPlacement": "auto",
"axisSoftMin": 0,
"barAlignment": 0,
"barWidthFactor": 0.6,
"drawStyle": "line",
"fillOpacity": 20,
"gradientMode": "opacity",
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"insertNulls": false,
"lineInterpolation": "linear",
"lineWidth": 1,
"pointSize": 5,
"scaleDistribution": {
"type": "linear"
},
"showPoints": "auto",
"showValues": false,
"spanNulls": false,
"stacking": {
"group": "A",
"mode": "none"
},
"thresholdsStyle": {
"mode": "off"
}
},
"displayName": "rx ↓",
"noValue": "None",
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": 0
}
]
},
"unit": "decbytes"
},
"overrides": []
},
"options": {
"annotations": {
"clustering": -1,
"multiLane": false
},
"legend": {
"calcs": [
"lastNotNull"
],
"displayMode": "list",
"enableFacetedFilter": false,
"overflow": "ellipsis",
"placement": "bottom",
"showLegend": true
},
"tooltip": {
"hideZeros": false,
"mode": "single",
"sort": "none"
}
}
},
"version": "13.1.0"
}
}
},
"panel-18": {
"kind": "Panel",
"spec": {
"data": {
"kind": "QueryGroup",
"spec": {
"queries": [
{
"kind": "PanelQuery",
"spec": {
"hidden": false,
"query": {
"datasource": {
"name": "s8uwo_x4k"
},
"group": "prometheus",
"kind": "DataQuery",
"spec": {
"editorMode": "code",
"exemplar": false,
"expr": "node_network_wireguard_node_graph{type=\"node\"}",
"format": "table",
"instant": true,
"legendFormat": "__auto",
"range": false
},
"version": "v0"
},
"refId": "A"
}
},
{
"kind": "PanelQuery",
"spec": {
"hidden": false,
"query": {
"datasource": {
"name": "s8uwo_x4k"
},
"group": "prometheus",
"kind": "DataQuery",
"spec": {
"editorMode": "code",
"exemplar": false,
"expr": "node_network_wireguard_node_graph{type=\"edge\"}",
"format": "table",
"instant": true,
"legendFormat": "__auto",
"range": false
},
"version": "v0"
},
"refId": "B"
}
}
],
"queryOptions": {},
"transformations": []
}
},
"description": "",
"id": 18,
"links": [],
"title": "Network Topology",
"vizConfig": {
"group": "nodeGraph",
"kind": "VizConfig",
"spec": {
"fieldConfig": {
"defaults": {},
"overrides": []
},
"options": {
"edges": {},
"layoutAlgorithm": "layered",
"nodes": {},
"zoomMode": "cooperative"
}
},
"version": "13.1.0"
}
}
},
"panel-21": {
"kind": "Panel",
"spec": {
"data": {
"kind": "QueryGroup",
"spec": {
"queries": [
{
"kind": "PanelQuery",
"spec": {
"hidden": false,
"query": {
"datasource": {
"name": "s8uwo_x4k"
},
"group": "prometheus",
"kind": "DataQuery",
"spec": {
"editorMode": "code",
"expr": "node_network_wireguard_peer_rx{job=\"$job\",instance=\"$node\",device=\"$interface\",name=~\"$peer\"}",
"legendFormat": "{{name}}",
"range": true
},
"version": "v0"
},
"refId": "A"
}
}
],
"queryOptions": {},
"transformations": []
}
},
"description": "Volume of incoming traffic from each wireguard peer.",
"id": 21,
"links": [],
"title": "Peer Receive",
"vizConfig": {
"group": "bargauge",
"kind": "VizConfig",
"spec": {
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": 0
}
]
},
"unit": "bytes"
},
"overrides": []
},
"options": {
"displayMode": "lcd",
"legend": {
"calcs": [],
"displayMode": "list",
"overflow": "ellipsis",
"placement": "bottom",
"showLegend": false
},
"maxVizHeight": 169,
"minVizHeight": 13,
"minVizWidth": 8,
"namePlacement": "auto",
"orientation": "horizontal",
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false
},
"showUnfilled": true,
"sizing": "auto",
"valueMode": "color"
}
},
"version": "13.1.0"
}
}
},
"panel-22": {
"kind": "Panel",
"spec": {
"data": {
"kind": "QueryGroup",
"spec": {
"queries": [
{
"kind": "PanelQuery",
"spec": {
"hidden": false,
"query": {
"datasource": {
"name": "s8uwo_x4k"
},
"group": "prometheus",
"kind": "DataQuery",
"spec": {
"editorMode": "code",
"expr": "node_network_wireguard_peer_tx{job=\"$job\",instance=\"$node\",device=\"$interface\",name=~\"$peer\"}",
"legendFormat": "{{name}}",
"range": true
},
"version": "v0"
},
"refId": "A"
}
}
],
"queryOptions": {},
"transformations": []
}
},
"description": "Volume of outgoing traffic to each wireguard peer.",
"id": 22,
"links": [],
"title": "Peer Transmit",
"vizConfig": {
"group": "bargauge",
"kind": "VizConfig",
"spec": {
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": 0
}
]
},
"unit": "bytes"
},
"overrides": []
},
"options": {
"displayMode": "lcd",
"legend": {
"calcs": [],
"displayMode": "list",
"overflow": "ellipsis",
"placement": "bottom",
"showLegend": false
},
"maxVizHeight": 169,
"minVizHeight": 13,
"minVizWidth": 8,
"namePlacement": "auto",
"orientation": "horizontal",
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false
},
"showUnfilled": true,
"sizing": "auto",
"text": {},
"valueMode": "color"
}
},
"version": "13.1.0"
}
}
},
"panel-4": {
"kind": "Panel",
"spec": {
"data": {
"kind": "QueryGroup",
"spec": {
"queries": [
{
"kind": "PanelQuery",
"spec": {
"hidden": false,
"query": {
"datasource": {
"name": "s8uwo_x4k"
},
"group": "prometheus",
"kind": "DataQuery",
"spec": {
"editorMode": "code",
"exemplar": false,
"expr": "time() - node_network_wireguard_peer_handshake{job=\"$job\",instance=\"$node\",device=\"$interface\",name=~\"$peer\"}",
"format": "table",
"instant": true,
"legendFormat": "__auto",
"range": false
},
"version": "v0"
},
"refId": "Handshake"
}
},
{
"kind": "PanelQuery",
"spec": {
"hidden": false,
"query": {
"datasource": {
"name": "s8uwo_x4k"
},
"group": "prometheus",
"kind": "DataQuery",
"spec": {
"editorMode": "code",
"exemplar": false,
"expr": "node_network_wireguard_peer_rx{job=\"$job\",instance=\"$node\",device=\"$interface\",name=~\"$peer\"}",
"format": "table",
"instant": true,
"legendFormat": "__auto",
"range": false
},
"version": "v0"
},
"refId": "Peer Receive"
}
},
{
"kind": "PanelQuery",
"spec": {
"hidden": false,
"query": {
"datasource": {
"name": "s8uwo_x4k"
},
"group": "prometheus",
"kind": "DataQuery",
"spec": {
"editorMode": "code",
"exemplar": false,
"expr": "node_network_wireguard_peer_tx{job=\"$job\",instance=\"$node\",device=\"$interface\",name=~\"$peer\"}",
"format": "table",
"instant": true,
"legendFormat": "__auto",
"range": false
},
"version": "v0"
},
"refId": "Peer Transmit"
}
}
],
"queryOptions": {},
"transformations": [
{
"group": "joinByField",
"kind": "Transformation",
"spec": {
"options": {
"byField": "public_key",
"mode": "outer"
}
}
},
{
"group": "filterFieldsByName",
"kind": "Transformation",
"spec": {
"options": {
"include": {
"names": [
"public_key",
"endpoint 1",
"Value #Handshake",
"Value #Peer Receive",
"Value #Peer Transmit",
"name 1"
]
}
}
}
},
{
"group": "organize",
"kind": "Transformation",
"spec": {
"options": {
"excludeByName": {
"name 2": true,
"name 3": true,
"persistent_keepalive": true
},
"includeByName": {},
"indexByName": {
"Value #Handshake": 2,
"Value #Peer Receive": 3,
"Value #Peer Transmit": 4,
"name 1": 0,
"name 2": 5,
"name 3": 6,
"public_key": 1
},
"renameByName": {
"Value": "Handshake",
"Value #Handshake": "Latest Handshake",
"Value #Peer Name": "Name",
"Value #Peer Receive": "Peer Rx",
"Value #Peer Transmit": "Peer Tx",
"device": "Interface",
"endpoint": "Allowed IPs",
"endpoint 1": "Allowed IPs",
"name": "Name",
"name 1": "Name",
"persistent_keepalive": "Persistent Keepalive",
"persistent_keepalive 1": "Persistent Keepalive",
"public_key": "Public Key"
}
}
}
},
{
"group": "sortBy",
"kind": "Transformation",
"spec": {
"options": {
"fields": {},
"sort": [
{
"field": "Latest Handshake"
}
]
}
}
}
]
}
},
"description": "",
"id": 4,
"links": [],
"title": "Active Peers",
"vizConfig": {
"group": "table",
"kind": "VizConfig",
"spec": {
"fieldConfig": {
"defaults": {
"color": {
"fixedColor": "text",
"mode": "fixed"
},
"custom": {
"align": "auto",
"cellOptions": {
"type": "color-text"
},
"filterable": false,
"footer": {
"reducers": []
},
"inspect": false
},
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": 0
},
{
"color": "red",
"value": 180
}
]
},
"unit": "none"
},
"overrides": [
{
"matcher": {
"id": "byName",
"options": "Latest Handshake"
},
"properties": [
{
"id": "unit",
"value": "dtdurations"
},
{
"id": "color",
"value": {
"mode": "thresholds"
}
},
{
"id": "custom.width",
"value": 145
},
{
"id": "mappings",
"value": [
{
"options": {
"from": 31556952,
"result": {
"color": "red",
"index": 0,
"text": "never"
}
},
"type": "range"
}
]
}
]
},
{
"matcher": {
"id": "byName",
"options": "Peer Rx"
},
"properties": [
{
"id": "unit",
"value": "decbytes"
},
{
"id": "custom.width",
"value": 100
}
]
},
{
"matcher": {
"id": "byName",
"options": "Peer Tx"
},
"properties": [
{
"id": "unit",
"value": "decbytes"
}
]
},
{
"matcher": {
"id": "byName",
"options": "Allowed IPs"
},
"properties": [
{
"id": "custom.width",
"value": 150
}
]
},
{
"matcher": {
"id": "byName",
"options": "Peer Tx"
},
"properties": [
{
"id": "custom.width",
"value": 100
}
]
},
{
"matcher": {
"id": "byName",
"options": "Name"
},
"properties": [
{
"id": "custom.width",
"value": 245
}
]
}
]
},
"options": {
"cellHeight": "sm",
"enablePagination": true,
"showHeader": true,
"sortBy": []
}
},
"version": "13.1.0"
}
}
},
"panel-6": {
"kind": "Panel",
"spec": {
"data": {
"kind": "QueryGroup",
"spec": {
"queries": [
{
"kind": "PanelQuery",
"spec": {
"hidden": false,
"query": {
"datasource": {
"name": "s8uwo_x4k"
},
"group": "prometheus",
"kind": "DataQuery",
"spec": {
"editorMode": "code",
"exemplar": false,
"expr": "label_replace(sum(irate(node_network_wireguard_peer_rx{job=\"$job\",instance=\"$node\",device=\"$interface\",name=~\"$peer\"}[$__rate_interval])), \"device\", \"$interface\", \"device\", \"\")",
"format": "time_series",
"instant": false,
"legendFormat": "recv {{device}}",
"range": true
},
"version": "v0"
},
"refId": "A"
}
},
{
"kind": "PanelQuery",
"spec": {
"hidden": false,
"query": {
"datasource": {
"name": "s8uwo_x4k"
},
"group": "prometheus",
"kind": "DataQuery",
"spec": {
"editorMode": "code",
"exemplar": false,
"expr": "label_replace(sum(irate(node_network_wireguard_peer_tx{job=\"$job\",instance=\"$node\",device=\"$interface\",name=~\"$peer\"}[$__rate_interval])), \"device\", \"$interface\", \"device\", \"\")",
"format": "time_series",
"instant": false,
"legendFormat": "trans {{device}}",
"range": true
},
"version": "v0"
},
"refId": "B"
}
}
],
"queryOptions": {},
"transformations": []
}
},
"description": "",
"id": 6,
"links": [],
"title": "Interface Traffic",
"vizConfig": {
"group": "timeseries",
"kind": "VizConfig",
"spec": {
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"axisBorderShow": false,
"axisCenteredZero": false,
"axisColorMode": "text",
"axisLabel": "",
"axisPlacement": "auto",
"barAlignment": 0,
"barWidthFactor": 0.6,
"drawStyle": "line",
"fillOpacity": 25,
"gradientMode": "none",
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"insertNulls": false,
"lineInterpolation": "linear",
"lineWidth": 1,
"pointSize": 5,
"scaleDistribution": {
"type": "linear"
},
"showPoints": "auto",
"showValues": false,
"spanNulls": false,
"stacking": {
"group": "A",
"mode": "none"
},
"thresholdsStyle": {
"mode": "off"
}
},
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": 0
},
{
"color": "red",
"value": 80
}
]
},
"unit": "bytes"
},
"overrides": [
{
"matcher": {
"id": "byFrameRefID",
"options": "B"
},
"properties": [
{
"id": "custom.transform",
"value": "negative-Y"
}
]
}
]
},
"options": {
"annotations": {
"clustering": -1,
"multiLane": false
},
"legend": {
"calcs": [],
"displayMode": "list",
"enableFacetedFilter": false,
"overflow": "ellipsis",
"placement": "bottom",
"showLegend": true
},
"tooltip": {
"hideZeros": false,
"mode": "single",
"sort": "none"
}
}
},
"version": "13.1.0"
}
}
},
"panel-7": {
"kind": "Panel",
"spec": {
"data": {
"kind": "QueryGroup",
"spec": {
"queries": [
{
"kind": "PanelQuery",
"spec": {
"hidden": false,
"query": {
"datasource": {
"name": "s8uwo_x4k"
},
"group": "prometheus",
"kind": "DataQuery",
"spec": {
"editorMode": "code",
"exemplar": false,
"expr": "irate(node_network_wireguard_peer_rx{job=\"$job\",instance=\"$node\",device=\"$interface\",name=~\"$peer\"}[$__rate_interval])",
"format": "time_series",
"instant": false,
"legendFormat": "rx",
"range": true
},
"version": "v0"
},
"refId": "A"
}
},
{
"kind": "PanelQuery",
"spec": {
"hidden": false,
"query": {
"datasource": {
"name": "s8uwo_x4k"
},
"group": "prometheus",
"kind": "DataQuery",
"spec": {
"editorMode": "code",
"expr": "irate(node_network_wireguard_peer_tx{job=\"$job\",instance=\"$node\",device=\"$interface\",name=~\"$peer\"}[$__rate_interval])",
"legendFormat": "tx",
"range": true
},
"version": "v0"
},
"refId": "B"
}
}
],
"queryOptions": {},
"transformations": [
{
"group": "labelsToFields",
"kind": "Transformation",
"spec": {
"options": {
"keepLabels": [
"endpoint",
"name",
"persistent_keepalive",
"public_key"
],
"mode": "columns",
"valueLabel": "name"
}
}
}
]
}
},
"description": "",
"id": 7,
"links": [],
"title": "Peer Traffic",
"vizConfig": {
"group": "timeseries",
"kind": "VizConfig",
"spec": {
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"axisBorderShow": false,
"axisCenteredZero": false,
"axisColorMode": "text",
"axisLabel": "",
"axisPlacement": "auto",
"barAlignment": 0,
"barWidthFactor": 0.6,
"drawStyle": "line",
"fillOpacity": 0,
"gradientMode": "none",
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"insertNulls": false,
"lineInterpolation": "linear",
"lineWidth": 1,
"pointSize": 5,
"scaleDistribution": {
"type": "linear"
},
"showPoints": "auto",
"showValues": false,
"spanNulls": false,
"stacking": {
"group": "A",
"mode": "none"
},
"thresholdsStyle": {
"mode": "off"
}
},
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": 0
},
{
"color": "red",
"value": 80
}
]
},
"unit": "bytes"
},
"overrides": [
{
"matcher": {
"id": "byFrameRefID",
"options": "B"
},
"properties": [
{
"id": "custom.transform",
"value": "negative-Y"
}
]
}
]
},
"options": {
"annotations": {
"clustering": -1,
"multiLane": false
},
"legend": {
"calcs": [
"lastNotNull"
],
"displayMode": "table",
"enableFacetedFilter": false,
"overflow": "ellipsis",
"placement": "bottom",
"showLegend": true,
"sortBy": "Last *",
"sortDesc": true
},
"tooltip": {
"hideZeros": false,
"mode": "single",
"sort": "none"
}
}
},
"version": "13.1.0"
}
}
}
},
"layout": {
"kind": "RowsLayout",
"spec": {
"rows": [
{
"kind": "RowsLayoutRow",
"spec": {
"collapse": false,
"layout": {
"kind": "GridLayout",
"spec": {
"items": [
{
"kind": "GridLayoutItem",
"spec": {
"element": {
"kind": "ElementReference",
"name": "panel-10"
},
"height": 2,
"width": 1,
"x": 0,
"y": 0
}
},
{
"kind": "GridLayoutItem",
"spec": {
"element": {
"kind": "ElementReference",
"name": "panel-11"
},
"height": 2,
"width": 23,
"x": 1,
"y": 0
}
},
{
"kind": "GridLayoutItem",
"spec": {
"element": {
"kind": "ElementReference",
"name": "panel-12"
},
"height": 5,
"width": 8,
"x": 0,
"y": 2
}
},
{
"kind": "GridLayoutItem",
"spec": {
"element": {
"kind": "ElementReference",
"name": "panel-4"
},
"height": 10,
"width": 16,
"x": 8,
"y": 2
}
},
{
"kind": "GridLayoutItem",
"spec": {
"element": {
"kind": "ElementReference",
"name": "panel-13"
},
"height": 5,
"width": 8,
"x": 0,
"y": 7
}
},
{
"kind": "GridLayoutItem",
"spec": {
"element": {
"kind": "ElementReference",
"name": "panel-22"
},
"height": 9,
"width": 24,
"x": 0,
"y": 12
}
},
{
"kind": "GridLayoutItem",
"spec": {
"element": {
"kind": "ElementReference",
"name": "panel-21"
},
"height": 9,
"width": 24,
"x": 0,
"y": 21
}
},
{
"kind": "GridLayoutItem",
"spec": {
"element": {
"kind": "ElementReference",
"name": "panel-6"
},
"height": 11,
"width": 24,
"x": 0,
"y": 30
}
}
]
}
},
"title": "Summary"
}
},
{
"kind": "RowsLayoutRow",
"spec": {
"collapse": false,
"layout": {
"kind": "GridLayout",
"spec": {
"items": [
{
"kind": "GridLayoutItem",
"spec": {
"element": {
"kind": "ElementReference",
"name": "panel-7"
},
"height": 14,
"width": 24,
"x": 0,
"y": 0
}
},
{
"kind": "GridLayoutItem",
"spec": {
"element": {
"kind": "ElementReference",
"name": "panel-18"
},
"height": 21,
"width": 24,
"x": 0,
"y": 14
}
}
]
}
},
"title": "Peer Transmit/Receive"
}
}
]
}
},
"links": [],
"liveNow": false,
"preload": false,
"tags": [],
"timeSettings": {
"autoRefresh": "",
"autoRefreshIntervals": [
"5s",
"10s",
"30s",
"1m",
"5m",
"15m",
"30m",
"1h",
"2h",
"1d"
],
"fiscalYearStartMonth": 0,
"from": "now-24h",
"hideTimepicker": false,
"timezone": "browser",
"to": "now"
},
"title": "Wireguard Network",
"variables": [
{
"kind": "QueryVariable",
"spec": {
"allowCustomValue": true,
"current": {
"text": "node",
"value": "node"
},
"definition": "label_values(node_uname_info, job)",
"hide": "dontHide",
"includeAll": false,
"label": "Job",
"multi": false,
"name": "job",
"options": [],
"query": {
"datasource": {
"name": "s8uwo_x4k"
},
"group": "prometheus",
"kind": "DataQuery",
"spec": {
"query": "label_values(node_uname_info, job)",
"refId": "StandardVariableQuery"
},
"version": "v0"
},
"refresh": "onDashboardLoad",
"regex": "",
"regexApplyTo": "value",
"skipUrlSync": false,
"sort": "disabled"
}
},
{
"kind": "QueryVariable",
"spec": {
"allowCustomValue": true,
"current": {
"text": "n1.opti.lan:9100",
"value": "n1.opti.lan:9100"
},
"definition": "label_values(node_uname_info{job=\"$job\"}, instance)",
"hide": "dontHide",
"includeAll": false,
"label": "Host",
"multi": false,
"name": "node",
"options": [],
"query": {
"datasource": {
"name": "s8uwo_x4k"
},
"group": "prometheus",
"kind": "DataQuery",
"spec": {
"query": "label_values(node_uname_info{job=\"$job\"}, instance)",
"refId": "StandardVariableQuery"
},
"version": "v0"
},
"refresh": "onDashboardLoad",
"regex": "",
"regexApplyTo": "value",
"skipUrlSync": false,
"sort": "disabled"
}
},
{
"kind": "QueryVariable",
"spec": {
"allowCustomValue": true,
"current": {
"text": "wg0",
"value": "wg0"
},
"definition": "label_values(node_network_wireguard_interface{job=\"$job\",instance=\"$node\"}, device)",
"hide": "dontHide",
"includeAll": false,
"label": "Interface",
"multi": false,
"name": "interface",
"options": [],
"query": {
"datasource": {
"name": "s8uwo_x4k"
},
"group": "prometheus",
"kind": "DataQuery",
"spec": {
"query": "label_values(node_network_wireguard_interface{job=\"$job\",instance=\"$node\"}, device)",
"refId": "StandardVariableQuery"
},
"version": "v0"
},
"refresh": "onDashboardLoad",
"regex": "",
"regexApplyTo": "value",
"skipUrlSync": false,
"sort": "disabled"
}
},
{
"kind": "QueryVariable",
"spec": {
"allowCustomValue": true,
"current": {
"text": "All",
"value": "$__all"
},
"definition": "label_values(node_network_wireguard_peer_handshake{job=\"$job\",instance=\"$node\"}, name)",
"hide": "dontHide",
"includeAll": true,
"label": "Peer",
"multi": false,
"name": "peer",
"options": [],
"query": {
"datasource": {
"name": "s8uwo_x4k"
},
"group": "prometheus",
"kind": "DataQuery",
"spec": {
"query": "label_values(node_network_wireguard_peer_handshake{job=\"$job\",instance=\"$node\"}, name)",
"refId": "StandardVariableQuery"
},
"version": "v0"
},
"refresh": "onDashboardLoad",
"regex": "",
"regexApplyTo": "value",
"skipUrlSync": false,
"sort": "disabled"
}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment