Add histogram_quantile() PromQL query for percentiles

The PromQL layer only had a fixed-width histogram() (per-bucket
counts), with no way to ask for p50/p95/p99. Adds
histogram_quantile(p, metric[range]), interpolating over each
series's retained raw sample values (linear interpolation between
closest ranks) rather than building a separate pre-aggregated
bucketed-histogram representation — exact for the data actually kept.
An optional bracketed range narrows the computation to a trailing
window, mirroring rate()'s range selector.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TeyhRfMYjMditek6geDRoQ
This commit is contained in:
Hugh Kaznowski
2026-09-07 12:34:00 +01:00
co-authored by Claude Sonnet 5
parent 4a0fe92ce8
commit dbe2ea9961
5 changed files with 239 additions and 42 deletions
+9
View File
@@ -381,6 +381,15 @@ const SECTIONS: DocSection[] = [
— the most-recent value per label combination in the active range, i.e. the counter collapsed to its
latest reading.
</li>
<li>
<span className="font-semibold text-text">
<Code>histogram_quantile(p, metric_name)</Code>
</span>{' '}
— the <Code>p</Code>th quantile (<Code>0</Code>–<Code>1</Code>, e.g. <Code>0.95</Code> for p95) of each
label combination's retained values, interpolated over the raw samples rather than pre-aggregated
buckets. Add a bracketed range to narrow to a trailing window instead of the whole active range, e.g.{' '}
<Code>histogram_quantile(0.95, durations[5m])</Code>.
</li>
</ul>
<p className="font-semibold text-text">Worked example</p>
<p>