Repository navigation
Description
Friction
#2194 makes the local-savings queries of k8s/monitoring/dashboards/ai-spend.json also count the token series from before #1672, which have no local and no operation label: a series without local counts as local when provider="gateway" and server!="cache", and a series without operation counts as chat. The last such sample was at about 2026-10-24T00:28Z (roadmap-service has 0 replicas), and Prometheus keeps 30 days, so after about 2026-11-23 no such series is in range and the mapping is dead code in 8 queries, in the recorded fixture tests/fixtures/recorded_queries/ai_spend_local_savings.yaml and in its tests.
What should happen
When count(last_over_time(devops_cli_ai_tokens_total{local=""}[30d])) is empty, the 8 queries select only local="true" and operation, and the record and tests of the old label sets go.
Acceptance criteria
- The check query above returns no series (record the date and output in the PR).
- The savings queries name no series without
local, and the dashboard tests pass with the record of the current label set only.
Source: #2194
Alternatives check of 2026-11-03: not-applicable.
Class: chore, no search.
Tool: none found.
Proposed design
Problem statement
The 8 local-savings queries of k8s/devops/dashboards/ai-spend.json still map token series from before the local label (#1672) and the operation label (#1623): a series without local counts as local when provider="gateway" and server!="cache", and a series without operation counts as chat. The last such sample was at about 2026-10-24T00:28Z, and Prometheus keeps 30 days, so it leaves the range at about 2026-11-23T00:28Z. The mapping is dead code in the 8 queries, in the fixture tests/fixtures/recorded_queries/ai_spend_local_savings.yaml, and in its tests. A reply reports that PR #5931 for #5914 replaces the queries, but at this commit the dashboard, fixture and tests still hold the fallback, so the removal remains; it starts only after the check query returns no series.
Acceptance criteria
Requirement: Savings queries select only labelled series
Each of the 8 savings queries of k8s/devops/dashboards/ai-spend.json SHALL select token series with local="true" only, and no savings expression SHALL contain a local="" selector or a provider="gateway", server!="cache" fallback.
Scenario: No fallback selector in a savings query
- WHEN The dashboard test reads each expression that
_savings_targetsreturns from the dashboard - THEN The test finds 8 expressions, none contains
local=""orprovider="gateway", server!="cache", and each contains thelocal="true"selectors for both operation branches.
Requirement: Fixture holds the current label set only
The fixture tests/fixtures/recorded_queries/ai_spend_local_savings.yaml SHALL hold only series that carry the local and operation labels, and its expr SHALL equal the query of the panel "Local Cloud Savings in Range".
Scenario: Fixture and panel agree
- WHEN The dashboard test loads the fixture and compares each record with the panel query and the dashboard prices
- THEN Every series has the
localandoperationlabels,exprequals the panel query, and eachresultequals the priced total of itsseries.
Requirement: Tests cover no series without the local label
The dashboard tests SHALL NOT model a series without the local label, and _is_local SHALL read the local label only.
Scenario: Test helpers read one label
- WHEN The dashboard test suite runs
- THEN
_is_localreturns true only forlocal="true",_priced_totalreads the operation from the labels with no default, and no test refers to a series withoutlocal.
Requirement: Panel descriptions and docs drop the fallback text
The description of each savings panel and the documentation SHALL NOT state that a series without the local or operation label counts as local or as chat.
Scenario: Descriptions and docs match the queries
- WHEN The dashboard and documentation tests read the descriptions,
k8s/README.md,src/devops_cli/docs/generator.pyanddocs/TELEMETRY.md - THEN No description, README line or generated page contains the text about a series from before the
localoroperationlabel, anddevops docs checkpasses.
Requirement: Fixture drops the deleted price rule key
The fixture SHALL NOT hold the key deleted_price_rule_first_sample, and the dashboard tests SHALL NOT read that key.
Scenario: Fixture and tests drop the deleted key
- WHEN The dashboard test suite runs and loads the fixture
- THEN The fixture has no
deleted_price_rule_first_samplekey and no test reads that key.
Existing Tool Considered
No open, maintained tool covers the need. The closest is grafana/dashboard-linter (https://github.com/grafana/dashboard-linter, fetched 2026-11-16), an open Grafana linter for Prometheus dashboards that cannot remove a dead PromQL fallback branch; promtool checks PromQL syntax but not Grafana dashboard JSON. The change deletes the branches in one dashboard, one fixture and their tests by hand: one pull request, about 30 minutes of edits and a few thousand tokens, plus the wait until the retention window closes. The alternatives check of 2026-11-03 gave not-applicable (class chore, no search, no tool found).
Key questions
None.
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsNew
- StatusShow more project fieldsNew
Activity
dan-petty commentedon Oct 24, 2026
Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones on the board.
The candidate updates dashboard queries and tests to remove outdated code.The change cleans up dead code and improves dashboard accuracy.The change affects dashboard correctness and removes obsolete logic.The work involves removing old queries and updating tests, which is straightforward.Both items work on the ai-spend dashboard, but the candidate removes old mappings while item #1668 adds new ones.fix(monitoring): the ai spend dashboard shows local savings for every…
dan-petty commentedon Oct 28, 2026
Refine cannot set this item to Ready at bb46660 until a person answers the questions below. Reply in a comment or edit the body, and the next refine round looks at the item again.
devops-cli-service commentedon Nov 3, 2026
Alternatives check: not-applicable
Class: chore. The check makes no search and no model call for an item of this class.
Tool: none found
Checked on 2026-11-03. A person decides what this means for the item. The check changes no label and closes no issue.
4 remaining items
dan-petty commentedon Nov 9, 2026
Premise check on 2026-11-09 confirms that the check query still returns series. The query
count(last_over_time(devops_cli_ai_tokens_total{local=""}[30d]))returned 30 series at 2026-11-09T18:18Z. The latest sample of an unlabelled series is from 2026-10-24T04:33:41Z. The Prometheus 30-day retention window expires at approximately 2026-11-23T04:33Z. This item cannot be built as written until that retention window expires. Removal of the fallbacks before that date violates acceptance criterion 1 and undercounts local savings for historical ranges.devops-cli-service commentedon Nov 9, 2026
Refine cannot set this item to Ready at d31717d until a person answers the questions below. Reply in a comment or edit the body, and the next refine round looks at the item again.
dan-petty commentedon Nov 16, 2026
Pull request #5931 (for #5914) replaces the local-savings queries of
ai-spend.json. They read the gateway token counterslitellm_input_tokens_metric_totalandlitellm_output_tokens_metric_total, and no query readsdevops_cli_ai_tokens_total{local=""}. The recordtests/fixtures/recorded_queries/ai_spend_local_savings.yamlholds gateway series only, and the tests of the old label sets are gone.After the merge, no work of this item is left, and the check query of criterion 1 does not apply. A person can close it as not planned.
devops-cli-service commentedon Nov 16, 2026
Status set to Ready at fccb781 (see proposed design in issue body).
devops-cli-service commentedon Nov 16, 2026
Staged: branch
chore/2202-drop-old-label-fallbacks-from-ai, draft pull request #5941. The pull request plans the item and closes no issue.The task groups, with the tokens of the inputs of each step, for a budget of 64000 tokens:
A model review of the plan found these points. They stop no draft, and a person judges them:
false_premiseat proposal (security): The plan claims the dashboard test fails when a savings query holds a fallback selector, but_misses_a_local_token_or_the_priceonly requires the twolocal="true"selectors and the absence of the label_replace clause, so a query that keeps alocal=""disjunct passes; the safeguard the security section names does not exist. Evidence: "tests/prometheus/test_k8s_monitoring_dashboards.pyfails when a savings query holds a fallback selector"contrived_testat tasks (1): Group 1 changes_misses_a_local_token_or_the_priceto require only the twolocal="true"selectors and to drop the label_replace clause, sotest_each_savings_query_prices_all_local_tokens_at_the_dashboards_pricespasses even when a savings query keeps thelocal=""andprovider="gateway", server!="cache"disjuncts; the acceptance criterion that the savings queries name no series withoutlocalis unguarded. Evidence: "setLOCAL_TOKEN_SELECTORSto the twolocal="true"selectors and drop the"operation", "chat", "", ""clause from_misses_a_local_token_or_the_price"spec_delta_wrongat spec ai-spend-pricing (The savings queries price the labelled local tokens at the reference price): The scenario "The record of the current label set" says every recorded series carrieslocal="true"andoperation, but the plan deletestest_the_records_hold_each_kind_of_series_and_a_range_before_the_price_ruleand adds no check of the kept record's labels;_priced_totalskips a series withoutlocal, so a stale series would pass the remaining test. Evidence: "Every recorded series carrieslocal="true"andoperation"false_premiseat proposal (security): The plan names a testtest_each_configmap_fits_kubectl_last_applied_annotationthat does not exist; the module holdstest_each_configmap_fits_kubectls_last_applied_annotation. Evidence: "test_each_configmap_fits_kubectl_last_applied_annotationfails when the ConfigMap grows past the limit."otherat tasks (3): Group 3'sdocumentationtells the implementer to updatesrc/devops_cli/telemetry/instruments.py, but the group'schangesdoes not list that file and itsdevops_cli_ai_tokens_totaldescription holds no fallback text, so the instruction would edit a file outside the plan. Evidence: "Updatesrc/devops_cli/telemetry/instruments.py"otherat tasks (2): Group 2 updates the fallback docstrings but leaves the docstring oftest_each_savings_query_prices_all_local_tokens_at_the_dashboards_prices, which still says the local tokens include the series from before thelocallabel; the plan'swhat_changessays the tests model no series withoutlocal. Evidence: "The local tokens include the series from before thelocal(fix(ai): local savings use one reference price per request kind for every process, and an unknown model or reference warns instead of pricing at $0 #1672)"The runs of the planner and the review made 129 model request(s), and used 8318299 input tokens and 211460 output tokens. The tool calls, in order:
read_spec({"capability":"ai-spend-pricing","requirement":"The savings queries price every range and every token series"})file_symbols({"path":"tests/prometheus/test_k8s_monitoring_dashboards.py"})read_file({"path":"tests/prometheus/test_k8s_monitoring_dashboards.py","start_line":326,"end_line":530})read_file({"path":"tests/prometheus/test_k8s_monitoring_dashboards.py","start_line":488,"end_line":540})read_file({"path":"tests/prometheus/test_k8s_monitoring_dashboards.py","start_line":1,"end_line":101})references({"name":"local=\"\""})references({"name":"server!=\"cache\""})read_file({"end_line":612,"path":"tests/prometheus/test_k8s_monitoring_dashboards.py","start_line":538})read_file({"end_line":360,"path":"k8s/README.md","start_line":335})search_code({"text":"before the 'local' label"})search_code({"text":"counts as local"})search_code({"text":"server!=\\\"cache\\\", operation"})search_code({"text":"\"title\": \"Local"})search_code({"text":"before the operation label"})read_file({"path":"src/devops_cli/docs/generator.py","start_line":1050,"end_line":1090})read_file({"path":"docs/TELEMETRY.md","start_line":198,"end_line":222})search_code({"text":"docs check"})search_code({"text":"last_over_time"})search_code({"text":"deleted_price_rule_first_sample"})search_code({"text":"ai_spend_local_savings"})read_file({"path":"tests/prometheus/test_dashboard_queries.py","start_line":1,"end_line":60})search_code({"text":"Savings"})search_code({"text":"Local Cloud"})read_file({"end_line":200,"path":"tests/prometheus/test_dashboard_queries.py","start_line":60})read_file({"path":"openspec/specs/gateway-caller-telemetry/spec.md","start_line":30,"end_line":70})read_file({"path":"openspec/specs/ai-spend-pricing/spec.md","start_line":130,"end_line":170})read_issue({"number":2194})find_issues({"terms":"ai-spend dashboard local savings"})read_issue({"number":5931})read_issue({"number":5784})read_issue({"number":5932})read_file({"end_line":745,"path":"tests/prometheus/test_k8s_monitoring_dashboards.py","start_line":692})search_code({"text":"def test_each_panel"})read_file({"end_line":300,"path":"tests/prometheus/test_dashboard_queries.py","start_line":200})read_file({"end_line":30,"path":"tests/fixtures/recorded_queries/ai_spend_local_savings.yaml","start_line":1})read_file({"end_line":150,"path":"k8s/devops/dashboards/ai-spend.json","start_line":136})search_code({"text":"ai_tokens"})search_code({"text":"def query"})read_file({"end_line":145,"path":"src/devops_cli/commands/prometheus.py","start_line":100})read_spec({"capability":"ai-spend-pricing","requirement":"The savings queries price every range and every token series"})search_code({"text":"deleted_price_rule_first_sample"})read_spec({"capability":"ai-spend-pricing","requirement":"The savings queries price every range and every token series"})file_symbols({"path":"tests/prometheus/test_k8s_monitoring_dashboards.py"})read_file({"path":"tests/prometheus/test_k8s_monitoring_dashboards.py","start_line":440,"end_line":530})search_code({"text":"deleted_price_rule_first_sample"})read_file({"path":"tests/prometheus/test_k8s_monitoring_dashboards.py","start_line":80,"end_line":105})read_file({"path":"tests/prometheus/test_k8s_monitoring_dashboards.py","start_line":400,"end_line":530})read_spec({"capability":"ai-spend-pricing","requirement":"The savings queries price every range and every token series"})search_code({"text":"reference_price_usd_per_token"})search_code({"text":"no behavior test"})search_code({"text":"_scenario_problems"})read_file({"path":"src/devops_cli/roadmap/stage/stage_change.py","start_line":1020,"end_line":1200})read_spec({"capability":"ai-spend-pricing","requirement":"The savings queries price every range and every token series"})read_file({"path":"src/devops_cli/roadmap/stage/stage_change.py","start_line":985,"end_line":1028})search_code({"text":"def _length_problems"})read_file({"path":"src/devops_cli/roadmap/stage/stage_change.py","start_line":790,"end_line":900})read_file({"path":"tests/prometheus/test_k8s_monitoring_dashboards.py","start_line":400,"end_line":470})search_code({"text":"counts as local"})search_code({"text":"before the operation label"})read_file({"path":"tests/prometheus/test_k8s_monitoring_dashboards.py","start_line":78,"end_line":102})read_file({"path":"src/devops_cli/docs/generator.py","start_line":1058,"end_line":1080})read_file({"path":"k8s/README.md","start_line":335,"end_line":360})read_file({"path":"tests/prometheus/test_k8s_monitoring_dashboards.py","start_line":435,"end_line":520})search_code({"text":"server!=\\\"cache\\\", operation"})search_code({"text":"_misses_a_local_token_or_the_price"})read_spec({"capability":"ai-spend-pricing"})read_file({"path":"tests/prometheus/test_k8s_monitoring_dashboards.py","start_line":380,"end_line":560})read_spec({"capability":"ai-spend-pricing","requirement":"The savings queries price every range and every token series"})read_file({"path":"tests/prometheus/test_k8s_monitoring_dashboards.py","start_line":80,"end_line":110})search_code({"text":"server!=\\\"cache\\\", operation"})search_code({"text":"before the operation label"})read_file({"path":"k8s/README.md","start_line":330,"end_line":365})read_file({"path":"src/devops_cli/docs/generator.py","start_line":1040,"end_line":1085})read_spec({"capability":"ai-spend-pricing","requirement":"The AI spend dashboard holds the reference prices"})search_code({"text":"def check"})search_code({"text":"\"docs check\""})search_code({"text":"ci test"})search_code({"text":"def docs"})repo_map({"directory":"src/devops_cli/commands"})read_file({"path":"src/devops_cli/commands/docs.py","start_line":1,"end_line":80})search_code({"text":"local"})read_file({"path":"src/devops_cli/commands/docs.py","start_line":180,"end_line":300})read_file({"path":"tests/prometheus/test_k8s_monitoring_dashboards.py","start_line":540,"end_line":575})references({"name":"local=\"\""})references({"name":"server!=\"cache\""})search_code({"text":"Remove that mapping"})search_code({"text":"before the 'local'"})callers({"symbol":"_savings_record"})callers({"symbol":"_priced_total"})search_code({"text":"_savings_record()"})search_code({"text":"_priced_total("})search_code({"text":"ai_tokens_total"})read_file({"path":"src/devops_cli/telemetry/instruments.py","start_line":1,"end_line":60})search_code({"text":"documentation: str | None"})search_code({"text":"class StageGroup"})read_file({"path":"src/devops_cli/roadmap/stage/stage_change.py","start_line":521,"end_line":580})search_code({"text":"def _manifest_problems"})search_code({"text":"def _other_problems"})read_file({"path":"src/devops_cli/roadmap/stage/stage_change.py","start_line":590,"end_line":650})read_file({"path":"src/devops_cli/commands/docs.py","start_line":80,"end_line":175})search_code({"text":"prometheus query"})read_file({"path":"k8s/devops/dashboards/ai-spend.json","start_line":300,"end_line":360})search_code({"text":"pending-person"})search_code({"text":"class StageCriterion"})read_spec({"capability":"gateway-caller-telemetry","requirement":"The dashboard counts each gateway call once"})search_code({"text":"Tokens Processed in Range"})list_files({"directory":"k8s/devops/dashboards"})list_files({"directory":"k8s/monitoring/dashboards"})find_issues({"terms":"savings queries"})read_issue({"number":5931})read_issue({"number":5925})read_issue({"number":5784})search_code({"text":"README"})search_code({"text":"k8s/README.md"})read_issue({"number":5932})read_issue({"number":2194})search_code({"text":"LLM and embedding tokens"})search_code({"text":"local: true"})read_file({"path":"src/devops_cli/telemetry/instruments.py","start_line":100,"end_line":120})search_code({"text":"test_each_configmap_fits_kubectl_last_applied_annotation"})search_code({"text":"fails when a savings query"})search_code({"text":"LAST_APPLIED_ANNOTATION_LIMIT_BYTES"})search_code({"text":"annotation limit"})read_file({"path":"tests/prometheus/test_k8s_monitoring_dashboards.py","start_line":195,"end_line":220})search_code({"text":"def _is_scenario_command"})search_code({"text":"def _is_code_identifier"})read_file({"path":"tests/prometheus/test_k8s_monitoring_dashboards.py","start_line":70,"end_line":130})read_file({"path":"tests/prometheus/test_k8s_monitoring_dashboards.py","start_line":395,"end_line":560})search_code({"text":"fits_kubectl_last_applied_annotation"})search_code({"text":"_misses_a_local_token_or_the_price"})search_code({"text":"LAST_APPLIED_ANNOTATION_LIMIT_BYTES"})search_code({"text":"LOCAL_TOKEN_SELECTORS"})read_file({"path":"tests/prometheus/test_k8s_monitoring_dashboards.py","start_line":190,"end_line":225})search_code({"text":"before the local"})read_file({"end_line":1075,"path":"src/devops_cli/docs/generator.py","start_line":1055})read_file({"path":"k8s/README.md","start_line":330,"end_line":360})read_file({"path":"tests/prometheus/test_k8s_monitoring_dashboards.py","start_line":419,"end_line":428})search_code({"text":"provider=\"gateway\""})read_file({"end_line":201,"path":"tests/prometheus/test_k8s_monitoring_dashboards.py","start_line":200})read_file({"path":"tests/prometheus/test_k8s_monitoring_dashboards.py","start_line":380,"end_line":620})list_files({"directory":"k8s/devops/dashboards"})read_file({"path":"k8s/devops/dashboards/ai-spend.json","start_line":85,"end_line":100})search_code({"text":"before the operation label"})search_code({"text":"server!=\\\"cache\\\", operation"})read_file({"end_line":160,"path":"k8s/devops/dashboards/ai-spend.json","start_line":140})read_file({"path":"tests/fixtures/recorded_queries/ai_spend_local_savings.yaml","start_line":20,"end_line":80})read_file({"path":"k8s/README.md","start_line":335,"end_line":365})read_file({"end_line":1080,"path":"src/devops_cli/docs/generator.py","start_line":1050})read_file({"end_line":220,"path":"docs/TELEMETRY.md","start_line":195})search_code({"text":"def check"})list_files({"directory":"src/devops_cli/commands"})file_symbols({"path":"src/devops_cli/commands/docs.py"})file_symbols({"path":"src/devops_cli/commands/ci.py"})read_file({"path":"src/devops_cli/commands/docs.py","start_line":43,"end_line":170})read_spec({"capability":"ai-spend-pricing"})references({"name":"deleted_price_rule_first_sample"})references({"name":"ai_spend_local_savings"})read_file({"end_line":110,"path":"tests/prometheus/test_k8s_monitoring_dashboards.py","start_line":70})search_code({"text":"test_each_configmap_fits_kubectls_last_applied_annotation"})search_code({"text":"Savings"})read_file({"end_line":735,"path":"k8s/devops/dashboards/ai-spend.json","start_line":610})read_spec({"capability":"ai-spend-pricing","requirement":"The savings queries price every range and every token series"})callers({"symbol":"LOCAL_TOKEN_SELECTORS"})callers({"symbol":"_is_local"})search_code({"text":"LOCAL_TOKEN_SELECTORS"})search_code({"text":"_is_local"})references({"name":"local=\"\""})references({"name":"server!=\"cache\""})search_code({"text":"before the 'local'"})search_code({"text":"description"})read_file({"end_line":2215,"path":"src/devops_cli/commands/ci.py","start_line":2150})search_code({"text":"label_replace"})file_symbols({"path":"src/devops_cli/prometheus/promql.py"})read_file({"end_line":415,"path":"src/devops_cli/prometheus/promql.py","start_line":190})search_code({"text":"SAVINGS_RECORD"})search_code({"text":"_savings_record"})read_file({"end_line":380,"path":"tests/prometheus/test_k8s_monitoring_dashboards.py","start_line":300})read_file({"end_line":1205,"path":"k8s/devops/dashboards/ai-spend.json","start_line":1185})search_code({"text":"grouping_labels"})search_code({"text":"falls_back_to_constant"})read_file({"end_line":830,"path":"tests/prometheus/test_k8s_monitoring_dashboards.py","start_line":755})search_code({"text":"readability_problems"})read_file({"end_line":660,"path":"tests/prometheus/test_k8s_monitoring_dashboards.py","start_line":615})read_file({"end_line":860,"path":"tests/prometheus/test_k8s_monitoring_dashboards.py","start_line":830})read_file({"end_line":360,"path":"tests/commands/k8s/test_stack_dashboards.py","start_line":300})read_file({"end_line":2040,"path":"src/devops_cli/commands/ci.py","start_line":1973})list_files({"directory":"openspec/changes"})file_symbols({"path":"src/devops_cli/commands/prometheus.py"})search_code({"text":"\"records\""})search_code({"text":"_expressions"})read_file({"end_line":480,"path":"tests/commands/k8s/test_stack_dashboards.py","start_line":380})search_code({"text":"DASHBOARD_EXPORTERS"})read_file({"end_line":280,"path":"tests/commands/k8s/test_stack_dashboards.py","start_line":230})search_code({"text":"counts as local"})search_code({"text":"Remove that mapping"})read_file({"end_line":230,"path":"tests/prometheus/test_k8s_monitoring_dashboards.py","start_line":195})read_file({"path":"tests/fixtures/recorded_queries/ai_spend_local_savings.yaml","start_line":1,"end_line":20})Tool calls: callers=4 (empty=0), file_symbols=6 (empty=0), find_issues=2 (empty=0), list_files=5 (empty=0), read_file=71 (empty=0), read_issue=9 (empty=0), read_spec=11 (empty=0), references=8 (empty=0), repo_map=1 (empty=0), search_code=80 (empty=4)
The stage job read the open pull requests and their files in 1 GraphQL request(s).
fix(monitoring): price local savings at the reference model (#5931)
dan-petty commentedon Nov 16, 2026
Done by #5931 (merged 2026-11-16 06:00Z). Every savings query of
k8s/devops/dashboards/ai-spend.jsonnow reads the gateway token counters of the local groups, so no query, recorded fixture, test helper or document on main holds the old-label fallback (local="", a series with nooperation). The plan pull request #5941 is closed because it has nothing left to change.