Skip to content

feat(k8s): alert on the daily Claude spend - #4246

Merged
dan-petty merged 3 commits into
mainfrom
feat/4222-daily-claude-spend-alert
Nov 9, 2026
Merged

dan-petty merged 3 commits into
mainfrom
feat/4222-daily-claude-spend-alert

Conversation

@dan-petty

Copy link
Copy Markdown
Owner

Add the rule group ai-spend to the Prometheus rules. ClaudeSpendDailyHigh fires when claude-sonnet-5-5 costs more than 15 USD in 24 hours. HostedSpendDailyHigh fires when all hosted models cost more than 25 USD in 24 hours. Both read devops_cli_ai_spend_usd_total, which prices a hosted call since #3665. A failed stage burst spent about 58 USD in one day, and a normal day is under 6 USD. The README lists both alerts with the first step: read the cost page of the AI spend dashboard, find the caller by the end_user label, and stop the job.

Closes #4222

Change: openspec/changes/archive/2026-11-09-4222-alert-on-the-daily-claude-spend/

@dan-petty dan-petty added type/feature Type feature: a new function scope/k8s Kubernetes commands, Helm charts, pods, services, and policies labels Nov 9, 2026
@dan-petty

Copy link
Copy Markdown
Owner Author

Test record of the author.

  • Red run (commit d842040, before the rules): uv run devops ci test tests/prometheus/test_k8s_monitoring_alerting.py gave 4 failed and 60 passed. The failures: the baseline rule set, the rule test of ai-spend, the README row test, and the promtool fixture of ai-spend (the group did not exist).
  • Green run: the same file, selected tests, 13 passed (the rule set, thresholds, README rows, promtool fixture, promtool check rules).
  • Full uv run devops ci under the shared lock: all 25 checks passed in 23m 6s. The host was loaded: pytest took 22m 36s, mypy 9m 56s and bandit 10m 17s.
  • Premise check on 2026-11-09 (read-only Prometheus query): the series devops_cli_ai_spend_usd_total has the labels job, instance, model, operation, provider and server, and no local label. For model="claude-sonnet-5-5" and job="roadmap-service" the 24 hour increase was 56.66 USD, close to the burst of about 58 USD. The Service pod started at 15:33Z, after the merge of fix(ai): price a hosted group call by the asked model #4231 at 14:32Z. The image is service:latest by digest, so the cluster cannot show that the image holds fix(ai): price a hosted group call by the asked model #4231. The rules are correct either way.
  • Known limit: increase misses the first sample of a series that starts inside the window. The series of the Service live for many days, so the rules use the plain form.

A person decides: whether 15 USD and 25 USD are the right thresholds. The issue asks to set them again with the data of one month.

@dan-petty
dan-petty marked this pull request as ready for review November 9, 2026 17:04
@dan-petty
dan-petty merged commit cc3b078 into main Nov 9, 2026
25 checks passed
@dan-petty
dan-petty deleted the feat/4222-daily-claude-spend-alert branch November 9, 2026 17:30
dan-petty pushed a commit that referenced this pull request Nov 9, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.102.0](v0.101.1...v0.102.0)
(2026-11-09)


### Features

* **k8s:** alert on the daily Claude spend
([#4246](#4246))
([cc3b078](cc3b078))


### Bug Fixes

* **k8s:** name the reference models in the ConfigMap template
([#4251](#4251))
([750cf78](750cf78))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: dan-petty-release[bot] <346998822+dan-petty-release[bot]@users.noreply.github.com>
dan-petty pushed a commit that referenced this pull request Nov 9, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.102.0](v0.101.1...v0.102.0)
(2026-11-09)


### Features

* **k8s:** alert on the daily Claude spend
([#4246](#4246))
([cc3b078](cc3b078))


### Bug Fixes

* **k8s:** name the reference models in the ConfigMap template
([#4251](#4251))
([750cf78](750cf78))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: dan-petty-release[bot] <346998822+dan-petty-release[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope/k8s Kubernetes commands, Helm charts, pods, services, and policies type/feature Type feature: a new function

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(k8s): alert on the daily Claude spend

1 participant