feat(prometheus): add histogram_Mode toggle for classic, native, and dual ingestion.#2818
Conversation
| enableNativeHistograms: self.histogramMode == 'native' || self.histogramMode == 'dual', | ||
| enableClassicHistograms: self.histogramMode == 'classic' || self.histogramMode == 'dual', |
There was a problem hiding this comment.
why do we need these?
There was a problem hiding this comment.
Removed. These were redundant intermediate variables; the logic has been moved directly into the resource specifications to simplify the component's internal API.
| scrapeNativeHistograms: self.histogramMode == 'native' || self.histogramMode == 'dual', | ||
| scrapeClassicHistograms: self.histogramMode == 'classic' || self.histogramMode == 'dual', |
There was a problem hiding this comment.
Can we avoid the intermediate variables and move this where it's used directly?
There was a problem hiding this comment.
Done. I have eliminated the intermediate variables and moved the logic directly into the Prometheus spec and ServiceMonitor endpoints.
I used std.map for the ServiceMonitor endpoints to keep the implementation DRY and consistent. I've verified the fix in a local kind cluster—the generated configuration correctly enables scrape_native_histograms across all targets and I've confirmed native samples are being ingested in the TSDB.
…nent This change addresses reviewer feedback by moving the histogram mode logic directly into the Prometheus spec and ServiceMonitor endpoints. By using std.map for endpoints, the implementation remains DRY while avoiding unnecessary top-level internal variables.
Description
This implementation introduces a
histogramModetoggle withinprometheus.libsonnet, providing the universal control requested in Issue #2784. By moving away from legacy bucket-based histograms at the library level, the solution maintains the integrity of thekube-prometheusmanifests as the source of truth.The implementation has been refactored to follow the maintainer's feedback: intermediate variables have been removed, and the logic is now applied directly within the resource specifications.
Key Features:
classic(default),native(high-resolution sparse histograms), anddual(parallel ingestion).std.mapto ensure consistent histogram settings across allServiceMonitorendpoints while maintaining a DRY codebase.dualmode allows for parallel ingestion of both formats, ensuring backward compatibility for existing dashboards during the transition.Closes #2784
Type of change
Development & Testing Guide
To provide a reproducible testing environment, I utilized a Kubernetes-in-Docker (Kind) cluster and a specialized toolchain container.
Initial Setup
Changelog entry
Add
histogramModetoggle to supportclassic,native, anddualhistogram ingestion modes across the stack.