Initial OpenClaw usage exporter

This commit is contained in:
2026-07-08 21:07:59 +00:00
commit f214e2eafe
5 changed files with 170 additions and 0 deletions
+32
View File
@@ -0,0 +1,32 @@
# openclaw-daily-tokens-exporter
Tiny FastAPI Prometheus exporter for OpenClaw daily token totals.
## What it exports
Reads OpenClaw session JSONL files and exposes today's totals at `/metrics`:
- `openclaw_daily_total_tokens`
- `openclaw_daily_input_tokens`
- `openclaw_daily_output_tokens`
- `openclaw_daily_cache_read_tokens`
- `openclaw_daily_cache_write_tokens`
- `openclaw_daily_reasoning_tokens`
- `openclaw_daily_usage_entries`
Timezone defaults to `Europe/Berlin`.
## Run locally
```bash
python3 -m venv .venv
. .venv/bin/activate
pip install -r requirements.txt
uvicorn app:app --host 127.0.0.1 --port 9487
```
## Env
- `OPENCLAW_SESSIONS_DIR` default: `/root/.openclaw/agents/main/sessions`
- `OPENCLAW_EXPORTER_TZ` default: `Europe/Berlin`
- `PORT` ignored by app directly; set it in the service/uvicorn command