Prometheus exporter for MetaCubeX/mihomo.
The exporter reads Mihomo API endpoints, calculates traffic deltas, and exposes Prometheus metrics for dashboards and alerting.
- Per-client traffic counters
- Per-outbound traffic counters (
outbound = chains[0]) - Active connection gauges
- Runtime/API metrics from:
/memory/traffic/version/proxies/rules
- Exporter health metrics
go run ./cmd/mihomo-exporterEndpoints:
http://127.0.0.1:9109/metricshttp://127.0.0.1:9109/healthzhttp://127.0.0.1:9109/readyz
docker build -t ghcr.io/suselz/mihomo-exporter:latest .
./deploy/docker-run-example.shCurrent compose example in deploy/docker-compose/docker-compose.yml runs exporter container with healthcheck.
docker compose -f deploy/docker-compose/docker-compose.yml up -dStop:
docker compose -f deploy/docker-compose/docker-compose.yml downEnvironment variables:
MIHOMO_URL(defaulthttp://192.168.0.1:9090)MIHOMO_CONNECTIONS_PATH(default/connections)EXPORTER_LISTEN_ADDR(default:9109)EXPORTER_METRICS_PATH(default/metrics)EXPORTER_SCRAPE_INTERVAL(default2s)EXPORTER_MAX_CLIENT_SERIES(default2000)EXPORTER_CLIENT_ALLOW_CIDRS(optional)EXPORTER_LOG_LEVEL(defaultinfo, values:debug|info|warn|error)
mihomo_client_download_bytes_total{client_ip}mihomo_client_upload_bytes_total{client_ip}mihomo_outbound_download_bytes_total{outbound}mihomo_outbound_upload_bytes_total{outbound}mihomo_total_download_bytes_totalmihomo_total_upload_bytes_totalmihomo_connections_total
See full metric catalog and internals in:
docs/developer-guide.md
- Dashboard:
grafana/dashboards/mihomo-exporter-dashboard.json