Operate
Usage and export
Usage facts per request and per GPU-second, the summary and CSV export, GPU-hours per day, sinks, retention, and how to compute cost per team in your own tools.
In short
opod counts what your GPUs did: requests, tokens, latency, time to first token and GPU-seconds, per endpoint, model, team, worker and job. It never records prompts or answers, and it never prices anything. The database only buffers these rows: connect a usage sink (Postgres, ClickHouse or S3) so they reach a store you keep, then join them with your price in your own tools.
When you need it
- Finance asks what each team's GPUs cost, and you need the hours to multiply by your price.
- You want p50 and p95 latency and time to first token per endpoint.
- The alert
usage.no-sinkfired: rows only buffer in the database. - You size the database: how many usage rows it keeps, and for how long.
- You check, before buying, how much VRAM sits idle on a cluster (
opodcp audit).
Do it
Read this month's numbers
export CP=https://cp.example.com export H="Authorization: Bearer $(kubectl -n opodcp get secret opodcp-admin -o jsonpath='{.data.token}' | base64 -d)" curl -s -H "$H" "$CP/api/v1/usage/summary?since=2026-10-01T00:00:00Z" \ | jq '.perEndpoint[] | {key, requests, promptTokens, completionTokens, gpuSeconds}'Export the rows
curl -s -H "$H" "$CP/api/v1/usage/export?since=2026-10-01T00:00:00Z&until=2026-11-01T00:00:00Z" -o usage-2026-10.csv curl -s -H "$H" "$CP/api/v1/usage/gpu-daily?from=2026-10-01&to=2026-10-31&format=csv" -o gpu-daily-2026-10.csvConnect a sink
On Connectors → usage, enter a DSN such as
clickhouse://opod@ch.example.com:8123/opod, press Verify, then Save. The control plane restarts once and sends the sink every row the spool still keeps, oldest first. The same through the API is under A save for each port.Set the retention
Save
OPODCP_USAGE_RETENTION(for example14d) on the same card. The spool then keeps raw rows for 14 days, and never deletes a row the sink has not taken.
Check it worked
curl -s -H "$H" $CP/api/v1/usage/retention | jq .
curl -s http://127.0.0.1:8080/metrics | grep -E '^opodcp_usage_sink_(connected|lag_rows|lag_seconds)'The second command needs kubectl -n opodcp port-forward svc/opodcp 8080:8080. A good answer: opodcp_usage_sink_connected 1, and opodcp_usage_sink_lag_rows near 0 a minute after the save. The retention answer shows the window and the sink's mark close to the newest row. The console's Usage page shows the numbers per team, model, endpoint and worker.
If it fails
| Symptom | Cause | Fix |
|---|---|---|
400 invalid on /usage/export | a bad since or until, or until before since | give RFC 3339 times, for example 2026-10-01T00:00:00Z |
Alert usage.no-sink | no sink, and 10,000 or more rows buffered | connect a sink |
Alert usage.sink-holding | the sink is behind and rows are kept past retention | fix the sink; or export, then POST /api/v1/usage/sink/skip?before=… |
0 rows in the sink and many in the spool | the sink's user may not create its table, or schema=manual with steps pending | Connectors → usage → Verify shows the missing grant or the SQL |
Every gpu_seconds is empty for one node | its cards are not measured | kubectl -n opodcp get pods -l app=opodcp-gpu-telemetry -o wide |
| A team-scoped caller sees fewer rows than an admin | the export is narrowed to that team | expected |
What is recorded
The control plane records quantities, never prices: requests, tokens, latency, time to first token and GPU-seconds, per endpoint, model, team, worker and job. You ship them to your own store and apply your own price there. Request content (prompts and answers) is never recorded.
Where the facts come from
| Kind | Written by | Carries |
|---|---|---|
request | each leader, one row per request, pulled by the control plane through a cursor; from 0.3.0, pushed by the leader instead (below) | tokens, latency, time to first token, outcome, key id, node |
occupancy | the control plane's meter, every 15 minutes and when a pod stops | GPU-seconds a serving worker held |
| job segment | the control plane, when a job's run segment ends | GPU-seconds of the job; workload_type is job and job_id is set |
From 0.3.0 the leader pushes its rows. A leader from core v0.4.0 sends one OTLP log record per request to the control plane (POST /otlp/v1/logs). It keeps each record in memory until the control plane answers, up to 64 MiB (about 440,000 records), so a control-plane outage loses nothing until that queue is full. The control plane pulls only an older leader, so a fleet that runs both versions keeps both lanes. A resend is stored once. The control plane renders the URL and the credential into every leader; there is nothing to set. GET /api/v1/usage/streams says per endpoint whether usage is push or pull, and missing counts the records a leader dropped at its cap.
A dedicated worker holds whole cards; a shared worker holds its budget's share of the card's measured size. Idle headroom and memory no plan explains belong to nobody, so a cell's GPU-seconds never exceed real card time. An unmeasured card yields no occupancy row.
Read it
curl -s -H "$H" "https://cp.example.com/api/v1/usage/summary?since=2026-10-01T00:00:00Z" | jq .perEndpoint
curl -s -H "$H" "https://cp.example.com/api/v1/usage/export?since=2026-10-01T00:00:00Z&until=2026-11-01T00:00:00Z" -o usage.csv
curl -s -H "$H" "https://cp.example.com/api/v1/usage/gpu-daily?from=2026-10-01&to=2026-10-31&format=csv" -o gpu-daily.csv| Route | Answers |
|---|---|
GET /api/v1/usage/summary | totals, errors, average latency, rpm60, and perEndpoint, perModel, perTeam, perWorker, perJob; with since (up to 8 days), latency[] per endpoint: p50 and p95 latency, TTFT and time per output token, and goodput against a stated SLO. endpoint= (repeatable) narrows it |
GET /api/v1/usage/export | CSV of the facts in a window (operator) |
GET /api/v1/usage/gpu-daily | GPU-hours per UTC day × endpoint × model × GPU class × workload type, JSON or CSV |
GET /api/v1/usage/retention | the window, the oldest row, the sink's mark and lag, and what holds rows past the window |
GET /api/v1/usage/streams | the pull from each leader: cursor, last pull, last error. From 0.3.0 also mode (push or pull), lastPushAt, lastSeenAt and missing; see REST API |
Export columns, in order: ts, tenant, cell, region, workload_type, kind, endpoint, team, model, protocol, api_key_id, user_id, prompt_tokens, completion_tokens, latency_ms, outcome, node_id, event_id, job_id, gpu_seconds, ttft_ms. since is inclusive and until exclusive; both are optional RFC 3339 timestamps, and a bad one or an until before since is 400 invalid. ts is RFC 3339 with nanoseconds, kind is request or occupancy (a job segment is the row whose workload_type is job), and ttft_ms is empty when no first token was measured (a non-streamed answer, a job). A team-scoped caller gets its own endpoints' rows and its team's job rows.
kind is request for a request a leader served and occupancy for a segment of GPU held with no tokens: a serving worker's 15-minute meter segment, and, from 0.3.2, a job's run segment (workload_type: job). On 0.3.0 a job's segment exports kind: request; filter on workload_type there.
The response headers say what the CSV cannot:
| Header | Value |
|---|---|
X-Opod-Usage-Since, X-Opod-Usage-Until | the window the export was cut with; absent = unbounded. A script stores the bound and passes it as its next since |
X-Opod-Usage-Retention | the spool window (720h0m0s) or forever |
X-Opod-Usage-Oldest | the oldest raw row still kept; absent when there is none |
The summary reads only since. Its perEndpoint, perModel, perTeam, perWorker and perJob rows each carry key, requests, promptTokens, completionTokens, errors and gpuSeconds; a perEndpoint row also carries the team and model recorded on its rows, so a deleted endpoint keeps its team. A perWorker key is <endpoint id>|<node id>; a perJob key is <team>|<job name>. Each table keeps the 50 busiest keys; use endpoint= to see one that falls outside them. A latency[] row carries p50LatencyMs, p95LatencyMs, ttftP50Ms, ttftP95Ms, tpotP50Ms, tpotP95Ms, their sample counts and, for an endpoint with an SLO, judged and good. An endpoint with no SLO reports no attainment.
gpu-daily takes from and to as UTC days (YYYY-MM-DD) and answers JSON, or CSV for format=csv or Accept: text/csv. Its columns: day, endpoint_id, endpoint_name, team, model, gpu_class, workload_type, tenant, cell, region, requests, prompt_tokens, completion_tokens, gpu_seconds_busy, gpu_seconds_idle, gpu_seconds_unmeasured. A minute counts as busy when the card's utilisation reading is above 0 and idle at 0; a card whose driver publishes no utilisation is unmeasured, never idle. Job GPU-seconds are all unmeasured. These are counters that retention never trims. A team-scoped caller reads its own team's rows.
The console's Usage page shows the same per team, model, endpoint and worker.
Ship it to your store
The database spool is an outage buffer, not a home. Connect a sink on the Connectors page (OPODCP_USAGE_DSN):
| Sink | DSN | Notes |
|---|---|---|
| Postgres | postgres://user@host:5432/db[?table=…][&schema=manual] | table opod_usage unless table= names another (schema.table allowed, lowercase); idempotent on (endpoint_id, event_id, kind); made by schema steps |
| ClickHouse | clickhouse://user@host:8123/db[?table=…][&schema=manual] | HTTP and JSONEachRow; clickhouses:// for TLS; port 8123 and database default when left out; table opod_usage by default; made by schema steps |
| Parquet | parquet:///dir | up to 0.3.6 only, removed in the release after: the directory is in the control plane's pod, which a restart wipes. Use S3 |
| S3 | s3://bucket/prefix?region=…[&endpoint=https://host:port][&pathStyle=0] | Parquet objects in any S3-compatible bucket; region us-east-1 when left out; a custom endpoint uses path-style addressing unless pathStyle=0; credentials from accessKey/secretKey in the DSN or AWS_ACCESS_KEY_ID/AWS_SECRET_ACCESS_KEY; plus gpu-daily/<day>.csv |
A DSN that carries a password or a key is a credential: the Connectors page seals it, or you name a Secret that holds the whole value. See Connectors.
How the rows get there:
- Every leader streams its request facts. The control plane pulls each stream through a cursor and writes the rows into the spool with an ingest sequence number.
- Every 15 s a shipping pass sends the sink batches of up to 1,000 rows from a durable mark, for at most 10 s. One batch is one S3 object or one insert. A backlog drains across passes.
- The mark moves only when the sink has taken the batch. Delivery is at least once. Postgres ignores a row it already holds, and S3 replaces the object of a replayed batch (as Parquet does its file, up to 0.3.6). ClickHouse drops a replayed batch only on a replicated table or once its deduplication window is set (Connector setup → ClickHouse); otherwise count distinct
(endpoint_id, event_id, kind). - A refused batch is sent again, the same batch, after 15 s × 2ⁿ (±20 %), capped at 5 minutes. A restart simply tries again.
A newly connected sink is sent every row the spool still keeps, oldest first. The previous sink keeps what it had. Rows written before ingest sequencing existed (an old upgrade) reach no sink; they are in the CSV export only.
| Signal | Meaning |
|---|---|
alert usage.no-sink (warning) | no sink is connected and 10,000 or more rows are buffered; the spool is the only copy |
alert usage.sink-holding | the sink is behind and holds rows past the retention window |
opodcp_usage_sink_connected | 1 when a sink is connected |
opodcp_usage_sink_lag_rows, opodcp_usage_sink_lag_seconds | rows the sink has not taken, and the age of the oldest |
GET /api/v1/connectors (admin), usage card | the backlog a switch would send |
Usage rows, from leaders to your sink
Rows waiting in the spool over 30 minutes · traffic and rows per pass are illustrative
Retention
Raw rows stay in the spool for OPODCP_USAGE_RETENTION, saved on the Connectors page: 30 days when unset, at least 24h, a Go duration (720h) or whole days (30d); 0 keeps every row. The trimmer runs every 10 minutes. GET /api/v1/usage/retention (viewer) shows the window, the oldest row, the sink's mark and lag, and what holds rows past the window; the API cannot change the window.
- A row the sink has not taken is never deleted. A sink that stays down fills the database, loudly: alert
usage.sink-holding, the doctor'susagerow and the metricopodcp_usage_sink_lag_seconds. - To accept a loss explicitly, export what you need, then
POST /api/v1/usage/sink/skip?before=<RFC 3339>(admin). The mark moves past every row the sink has not taken that is older thanbefore. The answer is the span as counted: the sequence range, the rows and their real time range. The eventusage.sink_skippedrecords who dropped what, and the next trimmer pass frees the rows. With no sink connected it answers400: there is no mark to move. - Rows that predate retention (from an upgrade or a restore) stay until you save
OPODCP_USAGE_TRIM_EXISTING=1. - Size: about 330 bytes per row with indexes. 30 days at 5 requests a second is about 13 million rows, roughly 4 GB.
Cost per team
The control plane knows how long each endpoint held its GPUs; your gateway knows which team sent which tokens. Cost per team is the join, in your BI tool, with your price. Split each endpoint's busy GPU-hours across teams by their share of its tokens that day, and label the result allocated:
-- opod_gpu_daily: the gpu-daily export. litellm_team: LiteLLM_DailyTeamSpend.
-- gateway_map(model_group, endpoint): your gateway's model list.
WITH gpu AS (
SELECT day, endpoint_name AS endpoint,
SUM(gpu_seconds_busy + gpu_seconds_unmeasured) / 3600.0 AS busy_h,
SUM(gpu_seconds_idle) / 3600.0 AS idle_h
FROM opod_gpu_daily WHERE workload_type = 'endpoint' GROUP BY day, endpoint_name
), tok AS (
SELECT t.date AS day, m.endpoint, t.team_id, SUM(t.prompt_tokens + t.completion_tokens) AS tokens
FROM litellm_team t JOIN gateway_map m ON m.model_group = t.model_group
GROUP BY t.date, m.endpoint, t.team_id
), share AS (
SELECT day, endpoint, team_id, tokens::float / SUM(tokens) OVER (PARTITION BY day, endpoint) AS share FROM tok
)
SELECT s.day, s.endpoint, s.team_id,
g.busy_h * s.share AS allocated_busy_gpu_hours,
g.busy_h * s.share * :price_per_gpu_hour AS allocated_cost
FROM share s JOIN gpu g USING (day, endpoint)
ORDER BY s.day, s.endpoint, s.team_id;Idle hours of a dedicated endpoint belong to the team that owns it (team on the export). Reconcile per endpoint and day: fewer gateway tokens than opod served means traffic reached the endpoint around the gateway.
Before you install: an idle-VRAM audit
opodcp audit reports the idle VRAM on any cluster, read-only, with no licence. It runs probe pods in a throwaway namespace and removes them.
opodcp audit --kubeconfig ~/.kube/config --duration 5m --price 2.50 --json > audit.jsonFlags: --namespace (default opodcp-audit), --duration (default 60 s, a sample every 10 s), --price (your price per GPU-hour; 0 = GPU-hours only), --json, --keep.
Last updated · Source: content/docs/control-plane-operate/usage.mdx · View as Markdown