Merge pull request #17249 from prometheus/beorn7/doc

docs: Clarify the handling of negative histograms
This commit is contained in:
Björn Rabenstein 2025-10-01 16:58:28 +02:00 committed by GitHub
commit 1b0f2b3017
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 10 additions and 0 deletions

View File

@ -14,6 +14,13 @@ sign for each element. The sign of a histogram sample is inverted by inverting
the sign of all bucket populations and the count and the sum of observations. the sign of all bucket populations and the count and the sum of observations.
The resulting histogram sample is always considered a gauge histogram. The resulting histogram sample is always considered a gauge histogram.
NOTE: A histogram with any negative bucket population or a negative count of
observations should only be used as an intermediate result. If such a negative
histogram is the final outcome of a recording rule, the rule evaluation will
fail. Negative histograms cannot be represented by any of the exchange formats
(exposition, remote-write, OTLP), so they cannot ingested into Prometheus in
any way and are only created by PromQL expressions.
## Binary operators ## Binary operators
Binary operators cover basic logical and arithmetic operations. For operations Binary operators cover basic logical and arithmetic operations. For operations
@ -102,6 +109,9 @@ operands and all subtractions result in a gauge histogram.
dropped. This occurs even if `__name__` is explicitly mentioned in `on` dropped. This occurs even if `__name__` is explicitly mentioned in `on`
(see https://github.com/prometheus/prometheus/issues/16631 for further discussion). (see https://github.com/prometheus/prometheus/issues/16631 for further discussion).
**For any arithmetic binary operation that may result in a negative
histogram**, take into account the [respective note above](#unary-operator).
### Trigonometric binary operators ### Trigonometric binary operators
The following trigonometric binary operators, which work in radians, exist in Prometheus: The following trigonometric binary operators, which work in radians, exist in Prometheus: