Skip to content

Analytics

Last updated: 2026-11-25T17:32:18-03:00 (UTC-3)

Who consumed what, how much, how it changed and what needs investigating, right in the console, without Grafana. Analytics reads the usage events recorded in PostgreSQL and separates demand, performance, consumers and cost. Flag: usage_analytics.

Usage is the console’s home page: a summary at the top; the latest requests are in Logs.

Analytics has these tabs (Quality, Tools, Cost estimates and Savings appear with their flags):

Tab What it shows
Usage Requests, reported tokens, average per event, coverage, demand and input/output series, comparison across models, providers and operations
Performance End-to-end average and p95, error and success rates over time and, with analytics_status_breakdown, the distribution by HTTP status
Consumers Usage by team, principal (the application) and key ID
Cost estimates Estimated cost by model, team and provider, with coverage; with cost_request_insights, the cost of one request (median, p95, p99, largest, mean) and the most expensive requests, each opening its trace; with customer_portal, the spend by customer organization; with pricing_coverage, the pricing coverage of the calls. Requires valuation
Tools With tool_call_analytics and the trace explorer: per tool, the calls, failed calls, success and error rate and average latency, and the calls over time (below)
Flag What it adds
analytics_comparison Comparison with the previous period of the same length
analytics_status_breakdown Distribution by HTTP status
analytics_export CSV export
analytics_rollups Daily aggregates, rebuilt every five minutes for today and yesterday
analytics_rollup_reads Periods longer than seven days read the closed days from the aggregates (p95 becomes unavailable)
stage_denominators Coverage per stage: how many inference requests reached each stage, refusals before persistence included
analytics_saved_views Saved views and dashboards: your filters, time range and widgets, private or shared read-only with one team
  1. Choose the period (15 min to 90 days, or custom) and the filters: principal, model, team, provider, key and operation.
  2. Click Apply analytics filters: the draft does not change the query until then.
  3. Inspect requests opens Request logs with the same filters and times, so you can see the requests behind a number. With the trace explorer on, View traces opens Traces on the same slice and time window, and a row’s error count opens its traces in error.

The CSV export and the estimates use exactly the same slice. Team roles pick one of their own teams; there is no global view for them.

Teams and organizations. A request counts for the organization it ran in. team selects a team’s requests of the organization it is in now, and organization selects what was recorded in that organization, by the teams it has now and by teams that have since moved away. So when a team moves, its earlier spend stays in the former organization’s totals and never enters the new one’s; the readers on each side are listed in when a team moves. The by-team ranking of a view with no team or organization filter (a global administrator’s) adds a team up across the organizations it has been in.

  • Buckets: hourly up to 7 days, daily beyond that, in UTC, displayed in the browser’s time zone.
  • Not measured ≠ zero. Latency and price that were not measured appear as missing; unknown cost never becomes zero.
  • Tokens: only those reported by the provider. Coverage says how many events had at least one counter.
  • Top 20: each dimension shows the 20 groups with the most events; a notice indicates when there is a cutoff. Search and sorting on screen act only on those 20.
  • Narrow screens: below 600 px each group of the breakdown is a card with every metric labelled; between that and a wide screen the group column stays in place while the metrics scroll sideways, with a hint under the table.
  • P95 is calculated from the events; it is not TTFT or the gateway’s isolated overhead.
  • Principal is the application that owns the key, not a console person.
  • Retention: if a retention policy deleted old events, Analytics says so, instead of showing an empty period as “no traffic”.

The charts have values accessible by pointer and keyboard, and wide tables scroll internally on phones.

Analytics reads persisted usage events, so a request refused before its event was written (no credential, a quota refusal, a provider failure before any answer) is not in it. With the operator flag stage_denominators (off by default; requires usage_analytics and PostgreSQL), the gateway also counts every model call (a POST to a /v1 or /v1beta inference route, or the realtime upgrade; not the file, batch, vector store, container, fine-tuning, video job, stored-response lifecycle, conversation, evaluation, passthrough or model-list routes, the console, health or internal calls) at each stage it reaches:

Stage Counted when
received The request reached the gateway
authenticated Its credential identified a key
admitted Every admission check passed and a provider send started, or the cache answered
responded An admitted request answered 2xx
persisted Its usage event was written
valued That event carries a priced valuation
reconciled Its budget reservation settled from a proven measurement
  • Cost on the request path: one atomic add in memory per stage reached; no database write. Each replica adds its counts to the current minute in PostgreSQL every 15 seconds (gateway_stage_counts, migration 181), and once more on shutdown; a failed write keeps the counts for the next flush. A count lands in the minute it was flushed, so the latest minute is still filling. Minutes are kept 90 days. Measured with gwbench -mock (same binary, flag off and on, alternating rounds): median p50 2.96 ms off and 2.98 ms on at concurrency 1, 9.26 ms off and 9.17 ms on at concurrency 16 (about 1,700 requests/s both), three rounds each: within noise.
  • Where: the Usage page shows Coverage per stage · last 24 hours with each stage’s count and its share of received. GET /api/v1/admin/analytics/stages?from=&to= (RFC 3339, whole minutes, at most 31 days; default the last 24 hours) answers the same with analytics:read.
  • Scope: the counts are installation-wide, across every replica and team; a team-scoped role cannot read them (403), and they carry no team, key or model.
  • Accuracy: a replica that crashes loses at most the counts of its last 15 seconds; turning the flag off stops counting at once. A request still running when a flush happens is counted at its later stages in a later minute. A flush whose write committed but whose answer timed out is added again on the next flush (at least once). reconciled is the gateway’s settlement decision; a background response (settled later, from its terminal response) is not counted there.
  • Upgrade: migration 181 adds the table. An older binary rejects the flag name in YAML; the table is ignored.

The screens show fixed breakdowns. For any other combination (cost per team per model per hour, 429s per key, provider and error code, blocks per guardrail and team), GET /api/v1/admin/analytics/query groups the same events (its organization dimension and filter are the organization a request ran in) by up to five dimensions and an optional minute, hour, day, week or month bucket in a time zone, with chosen metrics, exact filters, an order and a row limit, under the same permission, flag and team scope. m7 ai uses it to answer questions in plain language. Parameters, examples and limits: m7 ai.

With evaluation_metrics the same endpoint also answers over evaluation results: metrics such as pass_rate, mean_score, feedback_count and judge_cost_usd, dimensions such as evaluation, assessment and evaluation_value, joined with the dimensions of the judged request. The Quality tab of this screen is built on it, and the tab and range of the screen are kept in the address (#/analytics?tab=Quality&range=7d).

Usage → Tools answers “which tools do my agents call, how often do they fail and how long do they take”. Turn it on with:

features:
span_store: true
trace_explorer: true
tool_call_analytics: true

tool_call_analytics is a tenant read (with plan entitlements, the team’s plan must include it), off by default; it needs the trace explorer. The tab reads the tool spans the span store already keeps: an MCP tool the gateway ran for a request (execute_tool <tool>, with its MCP server, status and duration) and a tool a client reported running (client tool: its name is conversation structure and stays in the span’s attributes, so these are one row). An MCP listing (MCP operation) is a tool span but not a tool call, and is left out. It shows, for the Usage screen’s range and team:

  • Tiles: tool calls and how many tools, the average latency of the calls with a duration (a client-reported tool has none), the success rate (calls whose span is not an error) and the failed calls with the error rate.
  • Tool performance: one row per tool and server, most called first: calls (failed in brackets), success rate, error rate and average latency. A tool name opens the Traces screen on that tool’s spans of the range.
  • Tool usage over time: calls per hour (ranges up to 48 hours) or per day, the failed part stacked on top; an empty bucket is a gap.

The same figures come from GET /api/v1/admin/traces/tools with from, to (RFC 3339, up to 92 days; the last 24 hours by default) and an optional q in the query language (spans scope, for example team:payments or status:error), with logs:read. It answers totals (calls, errors, success_rate, error_rate, avg_latency_ms, tools), tools (each with tool, name, server, calls, errors, success_rate, error_rate, avg_latency_ms, timed_calls), series (the 8 most called tools and (other tools) with folded: true, each with points of at, calls and errors at step_seconds), read_store (database or analytics_store) and truncated (the range held more than 5,000 tool and step cells: narrow it; the rows and totals are read over the whole range apart from the series, so they stay exact up to 5,000 tools). Rates are fractions rounded to four decimals, latency in milliseconds to one decimal. It reads your teams only, of each what it recorded in its current organization, from the span engine the Traces screen reads.

  • Window of up to 90 days, 5 s per query and top 20 per dimension.
  • The panels are separate queries: under continuous writes, they may not reflect exactly the same instant.
  • Events are recorded best effort: failures before authentication and events lost to a database outage do not appear (count them with coverage per stage). For guaranteed recording, see durable receipts.
  • It is not a financial ledger.

Every route below needs a console session or an admin Bearer token, the role’s permission and, for writes, the X-CSRF-Token header; the full contract is in the API reference.

Route What it does
GET /api/v1/admin/analytics/rollups Daily usage aggregates, rebuilt every five minutes for today and yesterday (analytics_rollups), for team or for an organization administrator’s organization. A rollup row is kept per organization the requests ran in; a day not built yet, or waiting for the one-time rebuild after an upgrade, is listed in missing_days
POST /api/v1/admin/analytics/rollups/rebuild Rebuilds whole UTC days from the stored events, for late events or after a retention deletion. 204: every day of the range was rebuilt by the call. 202 with {"queued": true, "from": "…", "to": "…", "days": N}: N days were left to the background rebuild, because a day is too large for one statement and is built in slices, or because the range did not fit the two minutes of the call. Nothing else is needed: each queued day keeps its earlier rollup until its rebuild is done, and built_at of the listing moves when it is. 400: a range that is not 1 to 90 whole days. 503: the rebuild failed and nothing was queued

m7gtwcontact@m7gtw.com