Exports Prometheus metrics for Tailscale devices and keys
Go to file
Marcus Noble e5470dec4f
Merge pull request #1 from josh/device-last-seen
Device last seen
2023-10-02 10:23:54 +01:00
.github/workflows Fix github action 2023-07-30 14:00:13 +01:00
pkg Add device last seen gauge 2023-10-01 21:11:29 -07:00
Dockerfile Include the version in the initial log output 2023-07-30 13:51:16 +01:00
README.md Switch to using GitHub container registry 2023-07-29 21:59:59 +01:00
go.mod Initial release 2023-07-29 21:48:11 +01:00
go.sum Initial release 2023-07-29 21:48:11 +01:00
main.go Include the version in the initial log output 2023-07-30 13:51:16 +01:00

README.md

tailscale-exporter

Exports Prometheus metrics for Tailscale devices and keys.

Metrics

  • tailscale_devices_expiry_seconds_remaining - The number of seconds remaining until the device authentication expires
  • tailscale_devices_expiry_time - The timestamp (as Unix timestamp) that the device expires
  • tailscale_devices_update_available - Whether the device can be updated to a newer version of Tailscale or not
  • tailscale_keys_expiry_seconds_remaining - The number of seconds remaining until the key expires
  • tailscale_keys_expiry_time - The timestamp (as Unix timestamp) that the key expires

Configuration

The following environment variable can be used to configure the exporter:

  • TAILSCALE_API_KEY - A valid Tailscale API key [Required]
  • TAILSCALE_TAILNET - The Tailnet to export metrics for [Required]
  • PORT - The port to run the exporter on (Defaults to 8080)

Running with Docker

export TAILSCALE_API_KEY="my-tailscale-api-key"
export TAILSCALE_TAILNET="my-tailnet.github"
docker run --rm -it -p 8080:8080 -e TAILSCALE_API_KEY -e TAILSCALE_TAILNET ghcr.io/averagemarcus/tailscale-exporter:latest

Then visit: http://localhost:8080/metrics

Deploying to Kubernetes

apiVersion: v1
kind: Secret
metadata:
  name: tailscale-exporter
  labels:
    app.kubernetes.io/name: tailscale-exporter
stringData:
  TAILSCALE_API_KEY: xxxx
  TAILSCALE_TAILNET: xxxx
---
apiVersion: v1
kind: Service
metadata:
  name: tailscale-exporter
  labels:
    app.kubernetes.io/name: tailscale-exporter
  annotations:
    prometheus.io/scrape: "true"
    prometheus.io/port: "8080"
spec:
  type: ClusterIP
  ports:
  - port: 8080
    targetPort: 8080
  selector:
    app: tailscale-exporter
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: tailscale-exporter
  labels:
    app.kubernetes.io/name: tailscale-exporter
spec:
  replicas: 1
  selector:
    matchLabels:
      app.kubernetes.io/name: tailscale-exporter
  template:
    metadata:
      labels:
        app.kubernetes.io/name: tailscale-exporter
    spec:
      containers:
      - name: tailscale-exporter
        image: ghcr.io/averagemarcus/tailscale-exporter:latest
        imagePullPolicy: Always
        ports:
        - containerPort: 8080
          name: metrics
        envFrom:
        - secretRef:
            name: tailscale-exporter