Repository navigation
RFC: Local token usage log #3694
Replies: 7 comments 15 replies
|
"file" is kind of ambiguous, how about "stats" or "stats_file"? |
|
Can you specify if max mb and max days are signed? Like can we put -1 to get unlimited? |
|
Do you want to add basic perf stats to the record? TTFT and TPS would be nice to have. If you just add TTFT someone could figure out TPS as |
|
"or at 10 MB" sounds... chaotic. What's the exact behavior in this situation? Also, how many records does it take to reach 10 MB? |
Does this really belong in system-info? We already have config and telemetry endpoints.
Already in system-info? |
|
is there a way for us to collect the actual gpu model etc... ? |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Proposal size
Minor feature (a single PR)
Updates
max_size_mbandmax_daysUser story
For enterprise deployments running Lemonade there needs to be a way to keep a local record of how many tokens it processed, so we can report usage per machine over time to measure the actual value of local AI.
High-level design
An opt-in usage log. Once it's on, Lemonade appends one JSON line per LLM request to a local file.
Config
enabledfalsetelemetry.enabled(OTLP).path""<config dir>/usage/.content"none""none": counts only."full": also store prompts and responses.max_size_mb100-1for unlimited.max_days90-1for unlimited.Record
{"ts":"2026-09-28T19:02:11.412Z","host":"WS-ENG-041","lemonade_version":"11.8.1", "request":"chat.completions","model":"Qwen3-8B-GGUF","backend":"llamacpp","device":"gpu", "stream":true,"status":"ok","duration_ms":4210,"ttft_ms":182,"tokens_per_second":48.3, "input_tokens":812,"output_tokens":356,"cached_tokens":640, "tokens_reported":true,"tokens_estimated":false, "session_id":null,"client_ip":null}status:ok,error, oraborted(client disconnected).tokens_reported: false: the backend didn't return counts. The token fields are thennull, not0.tokens_estimated: true: the request was aborted mid-stream andoutput_tokenscounts the chunks sent before the disconnect.hostis the machine running Lemonade, even when the client is remote.session_idandclient_ipare best-effort. They're filled when the client provides them.Files
usage-YYYY-MM-DD.jsonl. One file per day.No added request latency
Records go into an in-memory queue and a background thread writes them. A slow disk or network share delays the log, not the request. If the queue fills, records are dropped and a
{"dropped": N}line is written once writing catches up.Coverage
LLM text requests only.
Endpoints Covered:
chat/completions,completions,responses(streaming and non-streaming), Anthropic/v1/messages, Ollamachat/generate, MCP, Embeddings, rerankingToken counts come from what each backend returns to Lemonade. No backend logs are parsed.
Backends supported:
Visibility
GET /health reports telemetry.usage_log with enabled, path, disk_usage_bytes and failed.
Out of scope
Aggregation, dashboards, and any UI. IT sums the files with their existing tools, for example:
Breaking changes
None.
Maintenance plan
content: "none"leaving out text, and thetokens_reported/tokens_estimatedflags.usage.Risks
No response
All reactions