Tailscale makes secure networking easy, but how do you monitor its performance? In this guide, we’ll set up Prometheus to collect key Tailscale metrics and gain insights into your mesh VPN connections. Learn how to track bandwidth usage and ensure your network is running smoothly—all with open-source monitoring tools! 🚀
Setting up Prometheus and Grafana is beyond the scope of this post. If you’re interested in setting them up, check out this guide.
Configure Tailscale
Tailscale offers clients metrics which can scraped by Prometheus. These are metrics as the amount of advertised routes in case of a subnet router, throughput for in and outbound packets. Both direct traffic as via the Tailscale DERP relay.
Lets check out the metics by simple running the command below on your tailscale machine. This will display all the metrics ones.
1tailscale metrics print
1# TYPE tailscaled_advertised_routes gauge
2# HELP tailscaled_advertised_routes Number of advertised network routes (e.g. by a subnet router)
3tailscaled_advertised_routes 0
4# TYPE tailscaled_approved_routes gauge
5# HELP tailscaled_approved_routes Number of approved network routes (e.g. by a subnet router)
6tailscaled_approved_routes 0
7# TYPE tailscaled_health_messages gauge
8# HELP tailscaled_health_messages Number of health messages broken down by type.
9tailscaled_health_messages{type="warning"} 0
10# TYPE tailscaled_inbound_bytes_total counter
11# HELP tailscaled_inbound_bytes_total Counts the number of bytes received from other peers
12tailscaled_inbound_bytes_total{path="derp"} 1500
13tailscaled_inbound_bytes_total{path="direct_ipv4"} 4089680
14tailscaled_inbound_bytes_total{path="direct_ipv6"} 0
15# TYPE tailscaled_inbound_dropped_packets_total counter
16# HELP tailscaled_inbound_dropped_packets_total Counts the number of dropped packets received by the node from other peers
17# TYPE tailscaled_inbound_packets_total counter
18# HELP tailscaled_inbound_packets_total Counts the number of packets received from other peers
19tailscaled_inbound_packets_total{path="derp"} 12
20tailscaled_inbound_packets_total{path="direct_ipv4"} 30362
21tailscaled_inbound_packets_total{path="direct_ipv6"} 0
22# TYPE tailscaled_outbound_bytes_total counter
23# HELP tailscaled_outbound_bytes_total Counts the number of bytes sent to other peers
24tailscaled_outbound_bytes_total{path="derp"} 5684
25tailscaled_outbound_bytes_total{path="direct_ipv4"} 2681236
26tailscaled_outbound_bytes_total{path="direct_ipv6"} 0
27# TYPE tailscaled_outbound_dropped_packets_total counter
28# HELP tailscaled_outbound_dropped_packets_total Counts the number of packets dropped while being sent to other peers
29tailscaled_outbound_dropped_packets_total{reason="error"} 0
30tailscaled_outbound_dropped_packets_total{reason="multicast"} 12
31# TYPE tailscaled_outbound_packets_total counter
32# HELP tailscaled_outbound_packets_total Counts the number of packets sent to other peers
33tailscaled_outbound_packets_total{path="derp"} 46
34tailscaled_outbound_packets_total{path="direct_ipv4"} 27918
35tailscaled_outbound_packets_total{path="direct_ipv6"} 0
Run the command below on the tailscale client/machine you want to get the metrics from. To ensure that the metrics are always available for Prometheus to scrape.
1sudo tailscale set --webclient=true
Now the metrics are available on http://tailscale-ip:5252/metrics
. You can verify if it all works by opening in your browser.
Configure Prometheus
For Prometheus to scrape the metrics, add the below configuration to your existing prometheus.yml
and restart prometheus.
You can adjust the scrape_interval
to your liking, and change the targets to your tailscale machines MagicDNS names.
1scrape_configs:
2 - job_name: 'tailscale'
3 scrape_interval: 10s
4 static_configs:
5 - targets:
6 - 'pi5.tail43c135.ts.net:5252'
7 - 'pi4.tail43c135.ts.net:5252'
8 relabel_configs:
9 - source_labels: [__address__]
10 regex: '([^:]+):\d+'
11 target_label: instance
12 replacement: '$1'
Grafana Dashboard
Now that Prometheus is scraping all the metrics. We can use Grafana to display them. All the tailscale metrics are starting with tailscaled_*
.
Or you can import this dashboard.