prometheus/model/textparse
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
..
testdata textparse: Refactor benchmark testdata for all types. (#15998) 2025-02-10 12:26:18 +00:00
README.md
benchmark_test.go feat: rename CreatedTimestamp to StartTimestamp (#17523) 2025-11-13 14:17:51 +00:00
interface.go feat: rename CreatedTimestamp to StartTimestamp (#17523) 2025-11-13 14:17:51 +00:00
interface_test.go feat: rename CreatedTimestamp to StartTimestamp (#17523) 2025-11-13 14:17:51 +00:00
nhcbparse.go Add histogram validation in remote-read and during reducing resolution (#17561) 2025-11-21 00:22:24 +01:00
nhcbparse_test.go feat: rename CreatedTimestamp to StartTimestamp (#17523) 2025-11-13 14:17:51 +00:00
openmetricslex.l bugfix: allow quoted exemplar keys in openmetrics text format 2024-11-12 15:29:44 +00:00
openmetricslex.l.go Update golangci-lint (#17478) 2025-11-05 13:47:34 +01:00
openmetricsparse.go feat: rename CreatedTimestamp to StartTimestamp (#17523) 2025-11-13 14:17:51 +00:00
openmetricsparse_test.go feat: rename CreatedTimestamp to StartTimestamp (#17523) 2025-11-13 14:17:51 +00:00
promlex.l UTF-8: Add support for parsing UTF8 metric and label names 2024-02-15 14:34:37 -05:00
promlex.l.go Update golangci-lint (#17478) 2025-11-05 13:47:34 +01:00
promparse.go feat: rename CreatedTimestamp to StartTimestamp (#17523) 2025-11-13 14:17:51 +00:00
promparse_test.go feature: type-and-unit-labels (PROM-39 implementation) (#16228) 2025-05-17 09:37:25 +00:00
protobufparse.go model/textparse: Remove unit validation in protobuf parsing (#16834) 2025-11-19 14:03:32 +01:00
protobufparse_test.go feat: rename CreatedTimestamp to StartTimestamp (#17523) 2025-11-13 14:17:51 +00:00

README.md

Making changes to textparse lexers

In the rare case that you need to update the textparse lexers, edit promlex.l or openmetricslex.l and then run the following command: golex -o=promlex.l.go promlex.l

Note that you need golex installed: go get -u modernc.org/golex