A gauge where a histogram should be fails silently

source: minio/minio#20999 — Fix: Change TTFB metric type to histogram

Prometheus does not validate metric types when it scrapes. It stores the samples it is given. The type only matters later, to the PromQL function reading them, and the histogram functions are strict about their input in a way that produces no error when it is wrong.

histogram_quantile() needs cumulative _bucket series with an le label. Give it series that have le labels but are declared as a gauge and it treats them as unrelated gauges. The result set is empty. An empty result in PromQL is not an error, so the dashboard panel is simply blank while every other panel keeps working.

That is how MinIO's time-to-first-byte distribution sat unusable for quantiles until I hit it while wiring up a latency chart. The fix was a one-line type change (minio/minio#20999, merged April 2025). The diff being one line is why it lasted: nobody reviews the type line, and tests check that a metric exists and moves, not that a quantile query over the scrape output returns a number.

Two habits I keep from it:

  • When a known-good metric returns nothing, treat it as a bug report, not as "no traffic yet".
  • If a metric exists to be quantiled, the test is histogram_quantile() against real scrape output, in CI.