Expand description
Read side of the analytics store (DW-043): dashboard series, Top-N reports, and the structured query endpoint’s translator.
Every query reads ONLY the rollup tables (the dashboard contract is
“week of traffic under 100 ms” — that is rollup-shaped work, not
raw-scan work). All dynamic values bind as SQL parameters; the ONLY
strings interpolated into SQL are schema identifiers chosen from
closed sets (DIM_COLUMNS) — the structured query endpoint never
accepts SQL text.
Structs§
- Dimension
Query - The custom-dimension query endpoint’s request body (DW-093): a
closed grammar over the
rollup_dimtable — never SQL text. - Dimension
Row - One custom-dimension query row (DW-093): aggregated metrics for one
(window, dimension name, value) tuple, read from the
rollup_dimtable. The dimension name is config-bounded (the rollup key); the value is the captured tag value. - Filters
- Equality filters on dimension columns (dashboard drill-down).
- Filters
Body - The filter map of a
StructuredQuery: column -> required value. - Governance
Audit Query - The governance audit endpoint’s request body (DW-084): a time
window over the
ai_governance_eventstable. - Governance
Event Row - One governance audit event row (DW-084): a raw
ai_governance_eventsrecord — the shadow-audit view of which consumer/team called which model and whether the governance layer allowed or denied it. - Journey
Row - One journey/funnel query row (DW-093): a raw
rawtable record for one correlation id — the per-request step in a business journey. Ordered by time ascending so the caller sees the request sequence. - McpTool
Call Query - Query parameters for MCP tool call records (DW-087).
- McpTool
Call Row - One MCP tool call row (DW-087).
- Prompt
LogQuery - The prompt-logs endpoint’s request body (DW-081): a time window
over the
ai_prompt_logstable, optionally filtered by consumer. - Prompt
LogRow - One prompt log row (DW-081): a raw
ai_prompt_logsrecord — the redacted prompt and response for one captured AI request. - Query
Row - The structured query endpoint’s row: group key (in the query’s
group_byorder) plus the full metric set. - Series
Point - One point of a dashboard series.
- Spend
Query - The spend query endpoint’s request body (DW-079): a closed grammar
over the
ai_spendtable — never SQL text from the caller. - Spend
Row - One spend summary row (DW-079): aggregated token and cost totals for one group key over a billing window.
- Structured
Query - The structured query endpoint’s request body (DW-043): a closed grammar translated to SQL — never SQL text from the caller.
- TopEntry
- One Top-N entry.
Enums§
- Dimension
Query Error - Why a dimension query was rejected before SQL was built.
- Governance
Audit Error - Why a governance audit query was rejected before SQL was built.
- Prompt
LogError - Why a prompt-logs query was rejected before SQL was built.
- Query
Error - Why a structured query was rejected before SQL was built.
- Spend
Query Error - Why a spend query was rejected before SQL was built.
- TopKind
- Top-N report kinds (the five frozen in the feature analysis).
Constants§
- DIM_
COLUMNS - The fixed dimension columns queries may group or filter by. The closed set the structured endpoint accepts; also the dashboard’s drill-down axes.
- SPEND_
GROUP_ COLUMNS - The dimension columns the spend summary may group by (DW-079). The
closed set the spend endpoint accepts — a subset of the
ai_spendtable’s columns (noprovider/versionto keep the billing view focused on who/what, not the routing detail).
Functions§
- dashboard
- Dashboard series: per-window metric points at a granularity (0=1m..3=1d), optionally split by ONE dimension and filtered — the drill-down axes of the dashboard data API.
- dimension_
query - Execute a validated custom-dimension query (DW-093): aggregate the
rollup_dimtable over a time range at a granularity, filtered by dimension name and optional value. Rows order by window start ascending, then request count descending within each window. - governance_
audit - Execute a governance audit query (DW-084): return the raw
ai_governance_eventsrows in a time window, newest first. Reads the RAW rows directly — governance events are per-check, not rolled up (the volume is orders of magnitude below the access record path). - journey_
query - Execute a journey/funnel query (DW-093): return all raw records
matching a correlation id, ordered by time ascending. Optional
time range filter narrows the scan. Reads the RAW
rawtable directly (journey analysis is per-request, not rolled up). Thecorrelation_idindex keeps the scan bounded. - mcp_
tool_ calls - Execute an MCP tool call query (DW-087): return the raw
mcp_tool_callsrows in a time window, newest first, optionally filtered by session id, consumer, or tool name. - prompt_
logs - Execute a prompt-logs query (DW-081): return the raw
ai_prompt_logsrows in a time window, newest first. Reads the RAW rows directly — prompt logs are per-request, not rolled up. Optionally filtered by consumer. - spend_
summary - Execute a validated spend query (DW-079): aggregate the
ai_spendtable over a billing window, grouped by the requested dimensions. Rows order by cost descending (the billing-relevant axis). Reads the RAWai_spendrows directly — spend is per-request, not rolled up (the volume is orders of magnitude below the access record path, and billing windows are short). - structured
- Execute a validated structured query. Range-aggregate shape: the window column is NOT grouped (per-window series is the dashboard endpoint’s job); rows order by request volume descending.
- top
- Top-N over a time range, summed across the FINEST granularity’s windows (summing finer windows loses nothing — the whole schema is additive).