Repository navigation
Closed
Labels
effort/mediumEffort Mediumpriority/p2-mediumPriority P2: standard workscope/monitoringGrafana, Prometheus, Loki, alerts and dashboardssource/agentFiled by an agenttype/bugType bug: the code does not do what it mustvalue/mediumValue Medium
Description
Problem
The local-savings panels of k8s/devops/dashboards/ai-spend.json (Local Cloud Savings in Range, the savings half of Projected 30-Day, 90-Day and 1-Year Run Rate, Local Hardware Savings Rate, Local Savings per Hour by Backend Server) show values about 1000 times too high. On 2026-11-16 at 01:35Z, with the default range of 6 h, Projected 30-Day Run Rate showed $20,143 of savings. Only the real local tokens at the owner's reference price give $19.31.
Two causes:
- The price constant is not the owner's reference price. The dashboard constant
reference_price_usd_per_tokenprices a local chat token at 2.5 USD (prompt) and 10 USD (completion) per million tokens. The owner decision of 2026-11-09 (fix(k8s): the ConfigMap template names the reference models #4241) values local tokens at the hosted price ofqwen3.8:27b: 0.035 USD and 1.50 USD per million (ai.reference_modelandai.price_overridesink8s/devops/configmap.example.yaml), which the spend reports of the Service use. The dashboard prices a prompt token 71 times higher. - The savings read the client label
local. Before fix(ai): do not classify gateway endpoint as local backend #5874 (v0.159.0, live from 2026-11-15 23:43Z), hosted DeepSeek calls through the gateway hadlocal="true"(fix(ai): do not classify gateway endpoint as local serving backend #5867). In the 6 h to 01:35Z, 62.7M DeepSeek tokens havelocal="true"(35.9M fromroadmap-stage, 26.8M fromroadmap-service). In the last hour onlylocal/qwen3.8:27btokens have it, so the fix works, but every range that holds the old points (up to the 30-day retention) still counts them.
Expected behavior
- The savings use the price of
ai.reference_modelandai.price_overrides, from one source, so the dashboard and the spend reports agree. - The savings count only the tokens of a local model group, from data that the fix of fix(ai): do not classify gateway endpoint as local serving backend #5867 does not change. For example, read the gateway's own token counters (
litellm_input_tokens_metric_total,litellm_output_tokens_metric_total) by the model group that a local backend serves, as fix(monitoring): read AI spend from the gateway counter #4724 does for spend.
Related
- fix(monitoring): read AI spend from the gateway counter #4724 (spend from the gateway counter), fix(monitoring): follow the step in the local-savings query windows #5784 (rolling windows of the savings queries), chore(monitoring): Drop old label fallbacks from AI spend dashboard #2202 (old-label fallbacks), fix(k8s): the ConfigMap template names the reference models #4241, fix(ai): do not classify gateway endpoint as local serving backend #5867.
Metadata
Metadata
Assignees
Labels
effort/mediumEffort Mediumpriority/p2-mediumPriority P2: standard workscope/monitoringGrafana, Prometheus, Loki, alerts and dashboardssource/agentFiled by an agenttype/bugType bug: the code does not do what it mustvalue/mediumValue Medium
Activity
dan-petty commentedon Nov 16, 2026
Both fix the local-savings panels in ai-spend.json, but #5784 corrects the rolling-window step while this corrects the price constant and switches the data source from the local label to gateway counters.dan-petty commentedon Nov 16, 2026
Note for the pull request of this item: #5924 (for #4724) changes the spend panels of
k8s/devops/dashboards/ai-spend.jsonand does not change the savings queries.rate(...[7d]) * 86400 * N. The savings target still reads$__range, and the panel description says so. When this item changes the savings target, it can use the same 7-day baseline, so that both values of a projection panel have one baseline.litellm_spend_metric_totalbymodelandapi_provider. The gateway token counters (litellm_input_tokens_metric_total,litellm_output_tokens_metric_total) carry the same two labels intests/fixtures/metrics/litellm.yaml.tests/fixtures/dashboard_queries/ai-spend.yamlholds promtool cases of the spend panels. The savings panels can add their cases to the same file.dan-petty commentedon Nov 16, 2026
Owner requirement, 2026-11-16, for
ai-spend.json:ollama-48gib-fast,ollama-64gib-standard, and the embedding backends. It shows no series that names only the gateway, such asvia llm-gateway.llm.svc.cluster.local:4000 (gateway)orllm-gateway via llm-gateway.llm.svc.cluster.local:4000 (gateway).api_providerandmodeloflitellm_spend_metric_total; put the provider first in the legend and name the panel by provider.The gateway series hold what the panel needs.
litellm_input_tokens_metric_totalandlitellm_output_tokens_metric_totalhaveapi_provider(ollama_chat,ollama,openrouter),modelandmodel_id.litellm_deployment_total_requests_totalmapsmodel_idtoapi_base:6388f432...ishttp://ollama-48gib-fast.llm.svc.cluster.local:11434/api/chat, andb311d896...ishttp://ollama-64gib-standard.... The two embedding deployments (api_provider="ollama",qwen3-embedding:0.6b) have noapi_base, so they need another name (for example the model). A join* on (model_id) group_left (api_base) max by (model_id, api_base) (litellm_deployment_total_requests_total)and alabel_replacethat keeps the service name give one series for each backend. The price is the price ofai.reference_model, as this issue says.Build after #5924 merges, because both change
k8s/devops/dashboards/ai-spend.json.fix(monitoring): read AI spend from the gateway counter (#5924)
devops-cli-service commentedon Nov 16, 2026
Released in v0.161.0: https://github.com/dan-petty/devops-cli/releases/tag/v0.161.0
devops-cli-service commentedon Nov 16, 2026
Live since 2026-11-16 06:35 UTC