feat(cloudwatch): take rates and resets of native histograms in PromQL (#10018)

rate, increase and delta of a histogram's range follow Prometheus
v3.16's histogramRate: the last histogram at the range's coarsest
schema less the first, each histogram before a counter reset added
back for a counter (the first taken as empty when the second follows a
reset), then extrapolated with the float path's factor, the count
standing in for the value. A counter reset is detected as
FloatHistogram.DetectReset detects one: a fall in the count, the zero
bucket or any bucket at the newer schema above the zero threshold, a
finer schema or a smaller zero threshold.

irate and idelta take the last two samples of either kind, resets and
changes count floats and histograms in time order, and a range of both
kinds has no rate with Prometheus's mixed-samples warning. Histograms
keep no counter reset hint, as the guide says rate treats every
histogram alike, so delta and idelta of histograms give Prometheus's
"this native histogram metric is not a gauge" warning.

Part of #7030.
This commit is contained in:
Priamo Germosen authored and GitHub committed 2026-12-02 18:22:46 -04:00
1 parent 8705f7b1fe
commit 83209f39f6
6 files changed
+441 -81

No files matched your search

+17 -5
View File
@@ -690,11 +690,23 @@ with `bool` too, and Prometheus's `incompatible sample types encountered for bin
says so. `sum` and `avg` add histograms with Kahan compensation, `avg` falling back to a running mean
when the sum overflows, and so do `sum_over_time` and `avg_over_time`; a group or a range of both
floats and histograms has no result, with Prometheus's warning (`PromQL warning: encountered a mix of
histograms and floats for aggregation`) in the response's `warnings`. `rate` and the other functions
over a histogram's range, and `histogram_quantile`, come in a later part; until then they leave
histogram samples out. Histogram behavior follows Prometheus's latest release, 3.16, whose histogram
behavior the guide describes, such as the `ignored histogram` annotation that 3.0 does not have; a
histogram's counter reset hint, which only that release's warnings read, is not kept.
histograms and floats for aggregation`) in the response's `warnings`.
`rate`, `increase` and `delta` over a histogram's range take its last histogram, at the coarsest
schema of the range, less its first, extrapolated as a float's change is, the count standing in for
the value; for `rate` and `increase` each histogram before a counter reset is added back, a reset
being a fall in the count, the zero bucket or a bucket, or a finer schema, as Prometheus detects one;
an OTLP data point's start time is not read, as Prometheus reads start times only behind its
experimental `st-storage` feature.
`irate` and `idelta` take the last two samples, `resets` and `changes` count over floats and
histograms in time order, and a range of both kinds has no `rate` or `irate`, with Prometheus's
`encountered a mix of histograms and floats` warning. A histogram keeps no counter reset hint, which
the guide's "every histogram, including delta histograms" also says, so `rate` treats each as a
counter, and `delta` and `idelta`, which expect gauge histograms, give Prometheus's `this native
histogram metric is not a gauge` warning. `histogram_quantile`, `histogram_fraction`,
`histogram_stddev` and `histogram_stdvar` come in a later part. Histogram behavior follows
Prometheus's latest release, 3.16, whose histogram behavior the guide describes, such as the
`ignored histogram` annotation that 3.0 does not have.
Selectors follow Prometheus 3: a metric name or label name may be quoted, which a name with a dot has
to be (`{"http.server.active_requests", "@resource.service.name"="myservice"}`), and a matcher is