Skip to content

Commit 74cbcac

Browse files
authored
Merge pull request #2576 from prometheus/beorn7/histogram
Update native histogram spec
2 parents 1d8da9d + fd50ced commit 74cbcac

File tree

1 file changed

+30
-28
lines changed

1 file changed

+30
-28
lines changed

content/docs/specs/native_histograms.md

Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -318,9 +318,7 @@ the exponential bucketing featured by the standard schemas is a bad match for
318318
the distribution to be represented by the histogram. Histograms with different
319319
custom bucket boundaries are generally not mergeable with each other.
320320
Therefore, schema -53 SHOULD only be used as an informed decision in specific
321-
use cases. (TODO: NHCB aren't fully merged into main as of now (2024-11-03).
322-
They are worked into this document as far as possible already. This information
323-
might not yet be relevant for released Prometheus versions.)
321+
use cases.
324322

325323
### Buckets
326324

@@ -688,8 +686,11 @@ message BucketSpan {
688686
// [...]
689687
```
690688

691-
(TODO: The above does not yet contain the custom values needed for NHCBs. Update
692-
once merged into main.)
689+
(TODO: The above does not yet contain the custom values needed for NHCBs. We do
690+
not need it right now because NHCB can be ingested via scraping classic
691+
histograms. However, it might still be useful to have custom buckets in the
692+
exposition format eventually, e.g. for federation, and for future schemas that
693+
might also utilize the custom values.)
693694

694695
Note the following:
695696

@@ -1117,8 +1118,9 @@ as just one series with their unmodified name. (Example: A histogram called
11171118
### Scraping classic histograms as NHCBs
11181119

11191120
The aforementioned NHCB is capable of modeling a classic histogram as a native
1120-
histogram. Prometheus can be configured to ingest classic histograms as NHCBs
1121-
rather than classic histograms. (TODO: Explain how to do that once it is merged.)
1121+
histogram. Via the boolean scrape config option
1122+
`convert_classic_histograms_to_nhcb`, Prometheus can be configured to ingest
1123+
classic histograms as NHCBs.
11221124

11231125
NHCBs have the same issue with limited mergeability as classic histograms, but
11241126
they are generally much less expensive to store.
@@ -1607,11 +1609,6 @@ the latter, refer to the PromQL documentation about
16071609
and
16081610
[functions](https://prometheus.io/docs/prometheus/latest/querying/functions/).
16091611

1610-
TODO: The Prometheus PromQL implementation is currently lagging behind what's
1611-
described in this section. This is not called out separately further down for
1612-
all cases. See [tracking
1613-
issue](https://github.com/prometheus/prometheus/issues/13934) for details.
1614-
16151612
### Annotations
16161613

16171614
The introduction of native histograms creates certain situations where a PromQL
@@ -1861,19 +1858,28 @@ native histogram:
18611858
- `idelta()` (For gauge histograms.)
18621859
- `irate()` (For counter histograms.)
18631860

1864-
TODO: `idelta` and `irate` are not yet implemented for histograms.
1865-
18661861
These functions SHOULD be applied to either gauge histograms or counter
18671862
histograms as noted above. However, they all work with both flavors, but if at
18681863
least one histogram of an unsuitable flavor is contained in the range vector, a
18691864
warn-level annotation is added to the result.
18701865

1871-
All these functions return no result for series that contain a mix of float
1872-
samples and histogram samples within the range. A warn-level annotation is
1873-
added for each output element missing for that reason.
1866+
`delta()`, `increase()`, and `rate()` return no result for series that contain
1867+
a mix of float samples and histogram samples within the range. `idelta()` and
1868+
`irate()` return no result for series where the last two samples within the
1869+
range are a mix of a float sample and a histogram sample. In either case, a
1870+
warn-level annotation is added for each output element missing for these
1871+
reasons.
18741872

18751873
All these functions return gauge histograms as results.
18761874

1875+
As usual, these functions attempt to reconcile different schemas by converting
1876+
the schema to a common one as far as possible. However, the functions applied
1877+
to counters (`increase()`, `rate()`, `irate()`) do not perform this conversion
1878+
for the 1st sample if there is a counter reset between the 1st and 2nd sample.
1879+
In this case, the 1st sample is not included in the calculation, so an
1880+
incompatible bucket layout between the 1st sample and the other samples is
1881+
simply ignored silently.
1882+
18771883
TODO: Preventing [extrapolation below
18781884
zero](https://github.com/prometheus/prometheus/blob/034d2b24bcae90fce3ac337b4ddd399bd2ff4bc4/promql/functions.go#L153-L159)
18791885
is currently not yet implemented (and might actually not make sense) for native
@@ -1896,7 +1902,6 @@ histogram to gauge histogram and vice versa does not count as a change for
18961902
histograms, but the function still works with gauge histograms, applying
18971903
explicit counter reset detection in this case. Furthermore, a change from
18981904
counter histogram to gauge histogram and vice versa is counted as a reset.
1899-
(TODO: Not implemented yet.)
19001905

19011906
The `histogram_quantile()` function has a very special role as it is the only
19021907
function that treats a specific “magic” label specially, namely the `le` label
@@ -1991,8 +1996,7 @@ definition of the schema of the histogram.
19911996

19921997
The following functions do not interact directly with sample values and
19931998
therefore work with native histogram samples in the same way as they work with
1994-
float samples: (TODO: Still need to verify that this is true for all of the
1995-
functions below. Need to update the documentation for some of them.)
1999+
float samples:
19962000

19972001
- `absent()`
19982002
- `absent_over_time()`
@@ -2007,14 +2011,12 @@ functions below. Need to update the documentation for some of them.)
20072011
- `timestamp()`
20082012

20092013
All remaining functions not mentioned in this section do _not_ work with native
2010-
histograms. Histogram elements in the input vector are silently ignored. (TODO:
2011-
Make sure this is the case, rather than treating histogram samples as floats
2012-
with value 0.) For `deriv()`, `double_exponential_smoothing()`,
2013-
`predict_linear()`, and all the `<aggregation>_over_time()` functions not
2014-
mentioned before, native histogram samples are removed from the input range
2015-
vector. In case any series contains a mix of float samples and histogram
2016-
samples within the range, the removal of histograms is flagged by an info-level
2017-
annotation.
2014+
histograms. Histogram elements in the input vector are silently ignored. For
2015+
`deriv()`, `double_exponential_smoothing()`, `predict_linear()`, and all the
2016+
`<aggregation>_over_time()` functions not mentioned before, native histogram
2017+
samples are removed from the input range vector. In case any series contains a
2018+
mix of float samples and histogram samples within the range, the removal of
2019+
histograms is flagged by an info-level annotation.
20182020

20192021
### Recording rules
20202022

0 commit comments

Comments
 (0)