mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #2370] [CLOSED] add lifetime useage statistics to monitoring #4012
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#4012
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Niko1221/Strata/pull/2370
Author: @wokhouse
Created: 10/14/2026
Status: ❌ Closed
Base:
main← Head:pr/usage-stats📝 Commits (6)
1c612ceserve: lifetime token statistics, kept across restarts, with time-window views66f4ab4docs: the usage_stats key, the usage view on /metrics, and the Usage paneldf2aaf7serve: Usage panel - opens on the 7-day view, and the browser remembers the choice3555729docs: the Usage panel's default view and the browser memory for the choicef721c2aserve: the edge cases that came out of testing the Usage panel64f426dserve: the Usage range buttons wrap on a phone📊 Changes
8 files changed (+647 additions, -8 deletions)
View changed files
📝
docs/DETAILS.md(+22 -1)📝
serve/runconfig.py(+3 -0)📝
serve/server.py(+37 -5)➕
serve/test_usage.py(+207 -0)➕
serve/usage.py(+244 -0)📝
serve/web/app.css(+14 -0)📝
serve/web/app.js(+97 -2)📝
serve/web/index.html(+23 -0)📄 Description
Branch
pr/usage-statsfromv0.1.43. Commits:1c612cec,df2aaf7a,f721c2ae, and64f426dc(code),66f4ab46and35557294(docs).Issue #2241 asks for this feature. The report there says:
Issue #35 (monitor totals only since boot) and PR #1707 (token analytics) are closed. #1707 added no persistent storage. No open pull request covers this.
What it changes
The monitor's request history covers the current run only. The token analytics from #1707 keep no data across restarts. This pull request adds an opt-in counter store in
serve/usage.py. It counts requests, prompt tokens read, prompt tokens reused, output tokens, prompt milliseconds, decode milliseconds, and MTP drafts offered and accepted. The store writes to a small JSON file next to the run config. The counters stay in that file after a restart.The store holds counters only. It holds no prompts, no answers, and no request bodies.
"usage_stats": trueinstrata-<model>.json, or add--usage-statstoserve/server.py.GET /metricsreturns ausageobject with lifetime totals and the1d,7d, and30dviews.?from_ts=<epoch>&to_ts=<epoch>.What it leaves alone
This change touches no engine file. It changes Python and the web app only, so no CUDA, HIP, or SYCL rebuild is needed. No default changes. With the flag off, the usage code does nothing, no file is written, and
/metricsreports{"enabled": false}. The Prometheus text output does not change.How I checked
serve/test_usage.pyis new and has 14 tests.serve.test_serverpasses 296 of 296.test_monitorpasses 10 of 10,test_prometheus6 of 6, andtest_runconfig9 of 9.from_tsgets no custom view. A request with a valid range gets a window. Junk in the parameters is ignored. The range works with?requests=all.Not tested
Windows and the HIP path are untested here. This box runs Linux only. I did not test
--batchor concurrency above 1. This box serves batch-1. This change adds no cost-per-token conversion. The counters are raw numbers, and no price table is added.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.