tsmetrics

command module
v0.0.0-...-0d3806c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 29, 2024 License: MIT Imports: 19 Imported by: 0

README

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
$ 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.

Documentation

Overview

This is partly tailscale's code. I made modifications to make it work with an oauth client

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL