A Prometheus exporter for TP-Link routers that collects WAN/LAN status, host information, and network metrics.
- WAN status (IPv4/IPv6, primary/backup interfaces)
- WAN uptime and traffic speed (uplink/downlink)
- LAN status and MAC addresses
- Online hosts detection with hostname, IP, speed, RSSI
- Automatic token refresh on authentication errors
- Go 1.22+
- TP-Link router with web management interface accessible from the host
git clone https://github.com/HuckOps/tplink_router_exporter
cd tplink_router_exporter
go build -o tplink-router-exporter .# Router management address
export ROUTER_ENDPOINT="http://192.168.0.1"
# Router admin password
export PASSWORD="your_password"
# Collection interval in seconds (default: 30)
export COLLECT_INTERVAL="30"./tplink-router-exporterAccess metrics at http://localhost:9100/metrics
Add to prometheus.yml:
scrape_configs:
- job_name: 'tplink_router'
static_configs:
- targets: ['localhost:9100']| Metric | Type | Labels | Description |
|---|---|---|---|
tplink_router_wan_status |
Gauge | name, ip, netmask, gateway, proto, primary_dns, secondary_dns |
WAN interface status |
tplink_router_wan_uptime |
Gauge | name |
WAN connection uptime (seconds) |
tplink_router_wan_tx_speed |
Gauge | name |
Upload speed (kbps/s) |
tplink_router_wan_rx_speed |
Gauge | name |
Download speed (kbps/s) |
name values: wan_1, wan_2, wan_v6_1, wan_v6_2
| Metric | Type | Labels | Description |
|---|---|---|---|
tplink_router_lan_status |
Gauge | ip, netmask, gateway, primary_dns, secondary_dns, ip_mode, mac |
LAN interface status |
| Metric | Type | Labels | Description |
|---|---|---|---|
tplink_router_online_hosts |
Gauge | — | Number of online hosts |
tplink_router_host_detail |
Gauge | hostname, ip, ipv6, mac, ssid |
Host detail |
tplink_router_host_tx_speed |
Gauge | hostname, ip |
Host upload speed (kbps/s) |
tplink_router_host_rx_speed |
Gauge | hostname, ip |
Host download speed (kbps/s) |
main.go # Entry point, HTTP server
├── config/ # Configuration (env vars)
├── pkg/tplink/ # Router API client
│ ├── api.go # Login, GetDS, token management
│ └── ds.go # Response structs
└── internal/collector/ # Prometheus collectors
├── network.go # WAN/LAN metrics
└── hosts.go # Host metrics
- Token is stored globally and auto-refreshed when the router returns
error_code != 0 - Collection interval defaults to 30 seconds, configurable via
COLLECT_INTERVALenvironment variable (in seconds) - All speed metrics are in kbps/s