r/SelfHosting • u/sabdohugo97 • 5h ago
Just shared my 9router LLM Gateway Prometheus Exporter — feedback wanted!
I wanted to visualize my 9router LLM usage, couldn't find an exporter, so I built one.
Hey everyone,
I've been using 9router as my LLM gateway for a while, and I really wanted to see my token consumption, cost burn rate, and provider breakdown in Grafana. After searching around, I realized there wasn't an existing Prometheus exporter that fit my setup.
Honestly, I’m not a professional developer—I just wanted a dashboard for my own use. armed with a lot of trial-and-error and a bit of "vibe coding," I managed to pull the data directly from the 9router SQLite database and expose it as Prometheus metrics.
It started as a personal weekend project, but it’s grown into a pretty solid tool, and I figured I’d open-source it in case anyone else in the community is looking for the same observability.
What it does:
\* Real-time monitoring: Tracks request rates, token usage (prompt vs. completion), and cost burn rates ($/sec).
\* Granular visibility: Breakdown by AI provider (Gemini, Claude, etc.) and specific LLM models.
\* Health checks: Monitors API health and service version status.
\* Ready-to-go: Includes a fully configured Grafana dashboard JSON and a systemd service template to keep the exporter running persistently.
Why I'm sharing this:
I'm honestly just a homelab enthusiast, so the code might not be "enterprise-grade." I’d love for some of you to take a look, review it, or even suggest improvements. It works for my setup, but I’m curious if it fits yours!
Check it out here:
hugosabdo97/9router-prometheus-exporter
Any feedback, pull requests, or questions are more than welcome. Happy self-hosting!