Skip to content

fix(monitoring): the ai spend dashboard shows local savings for every range in retention, priced at the reference model that devops ai cost uses - #2203

Merged
dan-petty merged 1 commit into
mainfrom
fix/2194-dashboard-local-savings
Oct 25, 2026
Merged

dan-petty merged 1 commit into
mainfrom
fix/2194-dashboard-local-savings

Conversation

@dan-petty

Copy link
Copy Markdown
Owner

Summary

The AI spend dashboard (k8s/monitoring/dashboards/ai-spend.json, uid ai-spend-telemetry) showed $0 local savings for 2026-10-01 to 2026-10-22, while Prometheus holds the tokens of that range. On main, the query of "Local Cloud Savings in Range" gives 0 at 2026-10-22T00:00Z over 21 d. There were three causes:

What changes:

  • DEFAULT_AI_REFERENCE_MODEL is gpt-4o (the owner's choice). text-embedding-3-small stays the embedding reference.
  • The dashboard has the hidden constant reference_price_usd_per_token: a PromQL vector of genai-prices' price of the default reference of each operation and token type. It is the one copy of each price in git. The eight savings queries multiply the local tokens by ${reference_price_usd_per_token:raw} and read only devops_cli_ai_tokens_total, so every range in the retention window is priced. The recording rule is deleted.
  • The queries count a series without local as local when its provider is gateway and its server is not cache, and a series without operation as chat. The gateway serves only local models: each model of k8s/llm/gateway/config.yaml, and of each of the 13 versions of the gateway configuration since 2026-09-15, has an api_base at an in-cluster Service, and each version sets store_model_in_db: false. Before fix(ai): embedding requests reach the spend ledger and the AI usage counters, priced against an embedding reference model #1623, the counters did not record embedding requests. This mapping can go when count(last_over_time(devops_cli_ai_tokens_total{local=""}[30d])) is empty, after about 2026-11-23 (the last such sample was at about 2026-10-24T00:28Z, and Prometheus keeps 30 d).
  • tests/fixtures/recorded_queries/ai_spend_local_savings.yaml records the answers of the live Prometheus to the panel query over two ranges, and the token series that it read. The test checks that the record is of the panel query, and that each answer is the total of the recorded series at the dashboard prices. No test, CI job or tools.lock entry uses promtool, so the test replays recorded answers of the real engine, as the OpenSpec tests replay the real OpenSpec.
  • The guard that keeps the default reference literal in config/defaults.py now finds a literal only where it names a reference model, because gpt-4o is also the default of settings that are no reference (for example, the tokenizer model of context_budget.py).

Live check, read-only, of the new "Local Cloud Savings in Range" expression for 2026-10-01T00:00Z to 2026-10-22T00:00Z ($__range = 1814400s), through kubectl exec into prometheus-server and through the Grafana MCP server (Prometheus 3.15.0):

Server Savings at gpt-4o
Workstation (ai.<domain>) $393.33
In-cluster Service (llm-gateway.llm.svc.cluster.local:4000) $29.69
Total $423.03

For 2026-10-22T22:00Z to 2026-10-24T22:00Z, where series with both labels, without local, and without both are, it gives $17.44, the total of the recorded series. A range query over 25 days and the grouped query of "Local Savings per Hour by Backend Server" gave no error.

Fail-to-pass: uv run devops ci fail-to-pass --base origin/main reports 4 failed on base.

Pending a person: after Argo CD applies the dashboard, set its time range to 2026-10-01 to 2026-10-21 and check that "Local Cloud Savings in Range" shows about $423.

Follow-up

Item

Closes #2194

Change: openspec/changes/archive/2026-10-24-2194-dashboard-local-savings/

… range in retention, priced at the reference model that devops ai cost uses

The AI spend dashboard showed $0 local savings for 2026-10-01 to
2026-10-22. The savings queries multiplied the tokens by a recording rule
that had samples only from 2026-10-24T05:21Z, they selected only the
series with the labels `local` and `operation`, which #1672 and #1623
added, and the rule priced chat tokens at gpt-4o-mini, not at the gpt-4o
of `devops ai cost`.

- DEFAULT_AI_REFERENCE_MODEL is gpt-4o.
- The hidden dashboard constant reference_price_usd_per_token holds
  genai-prices' price of each default reference, and the recording rule
  is deleted. The eight savings queries read only the token counter, so
  every range is priced.
- The savings queries count a series without `local` as local when the
  gateway served it (the gateway serves only local models), and a series
  without `operation` as chat.
- A test replays the recorded answers of the live Prometheus to the
  query of "Local Cloud Savings in Range": $423.03 for 2026-10-01 to
  2026-10-22.

Closes #2194
@dan-petty
dan-petty marked this pull request as ready for review October 24, 2026 23:31
@dan-petty
dan-petty merged commit 326766f into main Oct 25, 2026
17 checks passed
@dan-petty
dan-petty deleted the fix/2194-dashboard-local-savings branch October 25, 2026 00:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(monitoring): the ai spend dashboard shows local savings for every range in retention, priced at the reference model that devops ai cost uses

1 participant