prometheus/web/api
Dan Cech 8a233132e6
promql: track samples read per query
Add a per-query samples-read counter that distinguishes storage I/O
from the existing TotalSamples count. TotalSamples reports samples
loaded into the evaluator and so over-counts when a sample is reused
across multiple range-vector windows; samplesRead reflects what the
storage layer actually had to read.

For range-vector functions in range queries, samplesRead applies
delta semantics: step 0 counts the full window, later steps count
only the points not already present in the previous step's window.
For other query shapes samplesRead equals TotalSamples.

Expose the new counter:

- as `samplesRead` and `samplesReadPerStep` in /api/v1/query{,_range}
  stats responses (the per-step variant only with stats=all and the
  per-step stats feature flag enabled);
- as the `prometheus_engine_query_samples_read_total` Prometheus
  counter, reporting the cumulative samples-read across all queries;
- in the OpenAPI schemas.

Also update the per-step stats feature flag and querying API
documentation, and add unit tests covering instant queries, range
queries, range-vector functions, and subqueries.

Signed-off-by: Dan Cech <dcech@grafana.com>
2026-06-01 14:05:00 -04:00
..
testhelpers chore: fix httpNoBody issues from gocritic 2026-03-02 20:06:30 +01:00
v1 promql: track samples read per query 2026-06-01 14:05:00 -04:00