Switch to using tailscale oauth api

This removes the need to update the API key every 90 days.
This commit is contained in:
Abel Luck 2024-07-17 09:48:30 +02:00
parent 2bf137847d
commit b195bd1e8f
3 changed files with 88 additions and 8 deletions

View file

@ -73,7 +73,8 @@ Configuration values can be set using environment variables, or optionally loade
- **interval** (`TAILSCALESD_INTERVAL`): The interval on which the Tailscale API is polled in seconds. Default is `60`.
- **bearer_token** (`TAILSCALESD_BEARER_TOKEN`): The authentication token passed in the Authorization header (required).
- **tailnet** (`TAILSCALESD_TAILNET`): The Tailscale tailnet identifier (required).
- **api_key** (`TAILSCALESD_API_KEY`): The Tailscale API key (required).
- **client_id** (`TAILSCALESD_CLIENT_ID`): The Tailscale oauth client id (required).
- **client_secret** (`TAILSCALESD_CLIENT_SECRET`): The Tailscale oauth client secret (required).
#### Environment File
@ -83,7 +84,8 @@ You can also specify an environment file to load configuration values. The path
```env
TAILSCALESD_TAILNET=my-tailnet
TAILSCALESD_API_KEY=my-api-key
TAILSCALESD_CLIENT_ID=xxxx
TAILSCALESD_CLIENT_SECRET=yyyyy
TAILSCALESD_HOST=127.0.0.1
TAILSCALESD_BEARER_TOKEN=supersecret
```
@ -101,6 +103,9 @@ This service provides the following Prometheus metrics:
- **Description**: The number times a matrix sd host was unreachable. This counter increments each time a connection attempt to a matrix sd host fails.
- **Labels**:
- `device_hostname`: The hostname of the device that was unreachable.
- `tailscalesd_polling_up`
- **Type**: Gauge
- **Description**: Indicates if tailscalesd can access the tailscale devices API up (1) or down (0)
It also provides HTTP server metrics from [trallnag/prometheus-fastapi-instrumentator](https://github.com/trallnag/prometheus-fastapi-instrumentator)