Add cost monitoring alerts (cost-hourly-spike, cost-daily-budget) with configurable thresholds and dashboard/docs integration#3
Open
yash194 wants to merge 1 commit intosteadwing:mainfrom
Conversation
Collaborator
|
thanks for contributing @yash194 i hope it's fine , BTW great observation to find gap |
Author
|
@NILAY1556 Thats great ! thanks . Just one thing i had many more things in mind , should i wait as of now to open that issues and prs and open them after the revamp or i can open now. |
Collaborator
you can create the issue we can discuss overthere |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Solution Summary
This PR introduces first-class cost alerting with two new rules:
Both rules are based on llm.token_usage events with numeric costUsd, support existing rule overrides (enabled, threshold, cooldownMinutes), and automatically inherit evaluator protections (cooldown
deduplication + hourly alert cap).
Implementation Order and Changes
1. Core rule engine changes (src/core/rules.ts)
2. Dashboard status wiring (src/plugin/dashboard-routes.ts)
Added both new rule IDs to RULE_IDS so they appear in dashboard rule health/status:
3. Startup logging cleanup (src/core/engine.ts, src/index.ts)
Replaced hardcoded "8 rules active" log text with dynamic ${ALL_RULES.length} rules active to avoid future drift.
4. Plugin config schema + UI hints (openclaw.plugin.json)
Added explicit schema entries under rules.properties for:
Each supports:
Added UI hints:
5. Documentation updates (README.md, GUIDE.md)
Why sumInWindow + pushSummedBucket were introduced
sumInWindow
Needed because existing helper only counted entries.
Cost alerting requires summing numeric costUsd values across time ranges (60m/24h), not counting event frequency.
pushSummedBucket
Needed to avoid undercounting and memory growth issues:
Rule Logic (General)
For each incoming llm.token_usage event with numeric costUsd:
Compatibility and Risk
Validation Performed
Fixes #2