Skip to content

feat(dashboard): tokens and cache visualizations (input/output, cache hit ratio) - #15

Open
desek wants to merge 4 commits into
mainfrom
feat/tokens-per-second-panel
Open

feat(dashboard): tokens and cache visualizations (input/output, cache hit ratio)#15
desek wants to merge 4 commits into
mainfrom
feat/tokens-per-second-panel

Conversation

@desek

@desek desek commented Aug 14, 2026

Copy link
Copy Markdown
Owner

Summary

Adds a Tokens and cache section to the dashboard (between "Cost and tokens" and "Activity and outcomes") with three panels, designed against this stack's data model. Supersedes the earlier "Tokens per second by type" stat, which is removed.

1. Input and output tokens (diverging timeseries)

Output drawn upward, input downward from a centered zero baseline (input is negated in the query). Each point is increase() over the bucket, so it counts tokens generated in that interval.

2. Cache hit ratio (gauge, over the dashboard range)

cacheRead / (cacheRead + cacheCreation + input) — the share of all prompt (input-side) tokens served from cache. Uses last_over_time over $__range, consistent with the other range-scoped panels. Reads ~97.9% currently.

3. Cache hit ratio over time (timeseries)

The same ratio per bucket from increase().

Data-model note (deliberate design choice)

The two time series use increase() per bucket, not rate()/last_over_time. Measured on this stack, rate()/increase() return a value only where a session emitted more than one sample in the bucket, so idle intervals are blank on purpose. This was chosen over the always-continuous last_over_time because it counts true per-bucket tokens; the gauge, which only needs a range total, uses last_over_time.

Layout

"Cost by repository" is restored to full width; the "Activity and outcomes" and "Conversation and traces" sections shift down to make room. All panels honor the agent, repository, branch, and model variables.

Verification

Rendered in Grafana over a 6h range: output/input bars render around the active window (with honest idle gaps), the gauge reads 97.9%, and the ratio line tracks ~95–100% during activity.

desek added 2 commits August 14, 2026 06:00
Add a stat panel that shows average token throughput over the selected range,
split by token type (input, output, cache creation, cache read). Each type is a
separate, independently-scaled tile, so input and output stay readable next to
the much larger cache-read figure.

The per-second figure is the summed token total (last_over_time of each series)
divided by the range length in seconds, not rate(): each session is a
short-lived cumulative series, so rate() returns no value over an idle window.
The agent, repository, branch, and model variables filter the panel, matching
the other panels. Cost by repository is narrowed from full width to make room.

Verified in Grafana: the four type tiles render with data (input 3.46/s,
output 277/s, cacheCreation 1.61K/s, cacheRead 88.9K/s over a 6h range).
Replace the 'Tokens per second by type' stat with a 'Tokens and cache' section
holding three panels, per design discussion:

- Input and output tokens: a diverging timeseries, output drawn upward and input
  downward from a centered zero baseline (input negated in the query), each point
  increase() over the bucket so it counts tokens generated in that interval.
- Cache hit ratio: a gauge over the dashboard range, cacheRead / (cacheRead +
  cacheCreation + input) = share of prompt tokens served from cache.
- Cache hit ratio over time: the same ratio per bucket from increase().

The time series use increase() per bucket rather than last_over_time, a deliberate
choice: it counts tokens per interval but is blank on idle intervals, because
increase() needs more than one sample in the bucket on these short-lived
per-session counters. Cost by repository is restored to full width and the lower
sections shift down to make room.

Verified in Grafana over a 6h range: output/input bars render around the active
window, the gauge reads 97.9%, and the ratio line tracks ~95-100% during activity.
@desek desek changed the title feat(dashboard): add Tokens per second by type panel feat(dashboard): tokens and cache visualizations (input/output, cache hit ratio) Aug 14, 2026
desek added 2 commits August 14, 2026 11:30
Add a total-throughput timeseries to the Tokens and cache section for monitoring
tokens/sec by time of day. Each point is increase() over the bucket converted to
a per-second rate (increase * 1000 / $__interval_ms); idle intervals are filled
with 0 via 'or vector(0)', because no tokens flowing is a true zero rate, not
missing data, which keeps the daily curve continuous. Counts all token types, so
cache reads dominate the height; the bucket grows with the range so a wider
window smooths the line.

The section is rearranged into a 2x2 grid so the new panel fits without pushing
the lower sections further down: input/output and cache-ratio-over-time on top,
tokens/sec and the cache-ratio gauge below.

Verified in Grafana over 24h: a continuous line with a clear daily pattern,
mean ~9K tokens/sec and a ~95K/sec peak.
Scope the throughput monitor to the output token type only, so it tracks the
generation rate rather than total token movement dominated by cache reads.
Retitle to 'Output tokens per second'. Idle intervals still fill with 0 to keep
the daily curve continuous.

Verified in Grafana over 24h: mean ~47 output tokens/sec, peak ~800, with a
clear active-hours pattern and a zero baseline overnight.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant