prometheus/model/histogram
Björn Rabenstein b8d19543b8
Add histogram validation in remote-read and during reducing resolution (#17561)
ReduceResolution is currently called before validation during
ingestion. This will cause a panic if there are not enough buckets in
the histogram. If there are too many buckets, the spurious buckets are
ignored, and therefore the error in the input histogram is masked.

Furthermore, invalid negative offsets might cause problems, too.

Therefore, we need to do some minimal validation in reduceResolution.
Fortunately, it is easy and shouldn't slow things down. Sadly, it
requires to return errors, which triggers a bunch of code changes.
Even here is a bright side, we can get rud of a few panics. (Remember:
Don't panic!)

In different news, we haven't done a full validation of histograms
read via remote-read. This is not so much a security concern (as you
can throw off Prometheus easily by feeding it bogus data via
remote-read) but more that remote-read sources might be makeshift and
could accidentally create invalid histograms. We really don't want to
panic in that case. So this commit does not only add a check of the
spans and buckets as needed for resolution reduction but also a full
validation during remote-read.

Signed-off-by: beorn7 <beorn@grafana.com>
2025-11-21 00:22:24 +01:00
..
convert.go fix(histogram): handling +Inf bucket count and metric label 2025-10-28 20:29:44 +05:30
convert_test.go fix(histogram): handling +Inf bucket count and metric label 2025-10-28 20:29:44 +05:30
float_histogram.go Add histogram validation in remote-read and during reducing resolution (#17561) 2025-11-21 00:22:24 +01:00
float_histogram_test.go Add histogram validation in remote-read and during reducing resolution (#17561) 2025-11-21 00:22:24 +01:00
generic.go Add histogram validation in remote-read and during reducing resolution (#17561) 2025-11-21 00:22:24 +01:00
generic_test.go Add histogram validation in remote-read and during reducing resolution (#17561) 2025-11-21 00:22:24 +01:00
histogram.go Add histogram validation in remote-read and during reducing resolution (#17561) 2025-11-21 00:22:24 +01:00
histogram_test.go Add histogram validation in remote-read and during reducing resolution (#17561) 2025-11-21 00:22:24 +01:00
test_utils.go Apply analyzer "modernize" to the whole codebase 2025-08-27 14:48:41 +02:00