Setup
This Prometheus runs with the flags below and scrapes itself every 5s with 5 jobs, see its configuration and targets. It exposes prometheus_http_request_duration_seconds with both classic buckets, from 0.1s to 120s, and exponential native buckets, and each job stores it in a different representation.
--enable-feature=promql-nhcb-as-classic
| Job | Scrape options | Stored as |
classicClassic histograms, as before a migration. | Defaults | classic |
nhcbMigrated to native histograms with custom buckets, converted on scrape. | convert_classic_histograms_to_nhcb: true
| nhcb |
classic-and-nhcbIn the middle of a migration to NHCB, storing both. | convert_classic_histograms_to_nhcb: truealways_scrape_classic_histograms: true
| classic nhcb |
nativeMigrated to native histograms with exponential buckets. | scrape_native_histograms: trueconvert_classic_histograms_to_nhcb: true
| nhe |
classic-and-nativeIn the middle of a migration to exponential buckets, scraping both. | scrape_native_histograms: truealways_scrape_classic_histograms: true
| classic nhe |
- classic classic histogram series:
_bucket, _count and _sum
- nhcb native histogram with custom buckets (NHCB)
- nhe native histogram with exponential buckets
The native job also converts histograms exposed with classic buckets only, like prometheus_http_response_size_bytes, to NHCB, so it stores no classic histograms at all.
How queries read histograms
| Selector | Returns |
prometheus_http_request_duration_seconds_bucket, _count, _sumClassic histogram queries | Stored classic, plus converted from nhcb |
prometheus_http_request_duration_secondsNative histogram queries | Stored nhcb nhe |
Where a histogram is both stored as classic and converted from NHCB, stored classic data wins, so nothing is counted twice. Selectors matching the classic suffixes (_bucket, _count, _sum) by exact metric name are converted.