Skip to content

fix(metrics): correct task duration q95 and ship Grafana dashboard - #26

Merged
ruko1202 merged 2 commits into
mainfrom
fix/metrics-duration-and-grafana
Jul 2, 2026
Merged

fix(metrics): correct task duration q95 and ship Grafana dashboard#26
ruko1202 merged 2 commits into
mainfrom
fix/metrics-duration-and-grafana

Conversation

@ruko1202

@ruko1202 ruko1202 commented Jul 2, 2026

Copy link
Copy Markdown
Owner

Fixes two independent causes of a misleading Task Processing Duration q95 —
one in the exporter, one in the dashboard query — and makes the Grafana
dashboard discoverable and importable.

  • Record task_processing_duration_seconds only for polls that processed
    at least one task, so empty ticker polls no longer seed the histogram
    with empty-query DB latency and leave idle task types showing a stale q95
  • Rebalance histogram buckets: dense in the 1ms–1s working range (a ~50ms
    p95 previously fell into the wide [10ms,100ms] bucket and drifted under
    interpolation), sparse above 5s where processors time out at 30s
  • Wrap every dashboard histogram_quantile in rate() over the _bucket series
    so quantiles reflect the selected window instead of counters accumulated
    since process start
  • Set the dashboard's top-level id to null to fix "cannot change the ID of
    a dashboard" on import over an existing UID
  • Add grafana/ at the repo root with an importable copy of the metrics
    dashboard plus a README, linked from the main README

ruko1202 added 2 commits July 2, 2026 12:27
Internal processors poll on a fixed ticker, so most ticks process
zero tasks. The deferred prometheus timer recorded a duration for
every tick, seeding task_processing_duration_seconds with empty-query
DB latency and keeping histogram_quantile reporting a stale q95 for
idle task types (e.g. audit.write showed a duration with no tasks).
Record duration only when a poll processed >=1 task; errored polls
are excluded too.

Also rebalance the histogram buckets: dense in the 1ms-1s working
range (a ~50ms p95 previously fell into the wide [10ms,100ms] bucket
and drifted under interpolation) and sparse above 5s, where internal
processors time out at 30s and finer minute-scale buckets would only
add permanently-empty series.
Wrap every histogram_quantile in rate() over the _bucket series:
without it the quantile was computed from counters accumulated since
process start, so idle task types kept showing a stale q95. Set the
top-level dashboard id to null so importing over an existing UID no
longer fails with 'cannot change the ID of a dashboard'.

Add grafana/ at the repo root with an import-friendly copy of the
metrics dashboard and a README, and link it from the main README so
the ready-made dashboard is discoverable.
@ruko1202
ruko1202 merged commit 0030f7c into main Jul 2, 2026
4 checks passed
@ruko1202
ruko1202 deleted the fix/metrics-duration-and-grafana branch July 2, 2026 09:38
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