prometheus/docs/querying
György Krajcsovits db46de3dcb
feat(api): add histogram_format=native to query endpoints
Add a new optional histogram_format query parameter to /api/v1/query
and /api/v1/query_range. When set to native, native histograms in the
JSON response are emitted in a schema-aware shape.

For exponential schemas:

  {
    "count":          "<count>",
    "sum":            "<sum>",
    "schema":         <int>,
    "zero_threshold": "<threshold>",
    "zero_count":     "<count>",                       // when non-zero
    "negative_buckets": [ [ <index>, "<count>" ], ... ], // when non-empty
    "buckets":          [ [ <index>, "<count>" ], ... ]  // when non-empty
  }

zero_threshold is always emitted because, together with schema, it
fully describes the bucket layout. The negative/positive bucket
arrays carry the schema-defined bucket index and count, so empty
buckets that fall between non-empty ones are not transmitted.

For custom-bucket histograms (schema -53):

  {
    "count":      "<count>",
    "sum":        "<sum>",
    "schema":     -53,
    "boundaries": [ "<upper_bound>", ... ],
    "buckets":    [ [ <index>, "<count>" ], ... ]
  }

boundaries lists the bucket upper bounds; each bucket entry's index
is the 0-based index into boundaries.

This lets clients that already understand the schema (e.g. Grafana
rendering NHCB heatmaps) reconstruct every bucket including empty
custom-bucket slots, and is also substantially more compact than the
boundary-based representation for histograms with many buckets.

The existing boundary-based representation is unchanged when
histogram_format is absent or set to any other value.

Signed-off-by: György Krajcsovits <gyorgy.krajcsovits@grafana.com>
2026-05-22 19:13:40 +02:00
..
api.md feat(api): add histogram_format=native to query endpoints 2026-05-22 19:13:40 +02:00
basics.md Revert "PromQL: Promote duration expressions as stable" 2026-05-13 09:59:50 +02:00
examples.md Standardize doc page title handling 2025-05-28 21:37:27 +02:00
functions.md PromQL: Rename greatest, least, to max_of, min_of. 2026-05-19 13:07:16 +02:00
index.md Import querying documentation from prometheus/docs 2017-10-26 22:36:47 +02:00
operators.md docs: clarify 'stdvar' operator description 2026-03-23 11:12:46 +03:00
remote_read_api.md docs: remote read: Mention buf.build 2025-06-20 16:25:55 +02:00