Skip to content

drio/tsmetrics

Repository files navigation

Tailscale metrics

This tool exposes tailscale API data as prometheus metrics.

Grafana dashboard exposing tsmetrics

Usage

Install the latest golang and clone the repo.

You need to create an oauth client with the devices:read, network-logs:read scopes in your tailnet. Set those as env variables:

$ cat .env
OAUTH_CLIENT_ID=XXXXX
OAUTH_CLIENT_SECRET=YYYY
TAILNET_NAME=my_tailnet

$ bash -c 'set -a; source <(cat .env | \
        sed "s/#.*//g" | xargs); \
        set +a && go run . --wait-secs=240 --tsnet-verbose --addr=:9100 --resolve-names'

That runs tsmetrics as a service in your tailnet (you can run it outside your tailnet with: --regular-server). You will see tailscale requesting a login. Alternatively you can provide an auth key by setting the TS_AUTHKEY env var. The tool gets log and API data every 240 secs and updates a few prometheus metrics (we will add more metrics in the future):

tailscale_hosts
tailscale_rx_bytes
tailscale_tx_bytes
tailscale_rx_packets
tailscale_tx_packets

You can then configure your prometheus instance to scrap the exporter and from there you can visualize the metrics with your visualization tool of choice.

Notice that Network flow logs are not available in the free Tailscale plan.

About

A prometheus exporter for tailscale API data

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published