Documentation

prometheus.histogramQuantile() function

prometheus.histogramQuantile() is experimental and subject to change at any time.

prometheus.histogramQuantile() calculates a quantile on a set of Prometheus histogram values.

This function supports Prometheus metric parsing formats used by prometheus.scrape(), the Telegraf promtheus input plugin, and InfluxDB scrapers available in InfluxDB OSS.

Function type signature
(<-tables: stream[{B with le: D, _field: C}], quantile: float, ?metricVersion: A, ?onNonmonotonic: string) => stream[E] where A: Equatable, C: Equatable, E: Record

For more information, see Function type signatures.

Parameters

quantile

(Required) Quantile to compute. Must be a float value between 0.0 and 1.0.

metricVersion

Prometheus metric parsing format used to parse queried Prometheus data. Available versions are 1 and 2. Default is 2.

tables

Input data. Default is piped-forward data (<-).

onNonmonotonic

Describes behavior when counts are not monotonically increasing when sorted by upper bound. Default is error.

Supported values:

  • error: Produce an error.
  • force: Force bin counts to be monotonic by adding to each bin such that it is equal to the next smaller bin.
  • drop: When a nonmonotonic table is encountered, produce no output.

Examples

Compute the 0.99 quantile of a Prometheus histogram

import "experimental/prometheus"

prometheus.scrape(url: "https://127.0.0.1:8086/metrics")
    |> filter(fn: (r) => r._measurement == "prometheus")
    |> filter(fn: (r) => r._field == "qc_all_duration_seconds")
    |> prometheus.histogramQuantile(quantile: 0.99)

Compute the 0.99 quantile of a Prometheus histogram parsed with metric version 1

import "experimental/prometheus"

from(bucket: "example-bucket")
    |> range(start: -1h)
    |> filter(fn: (r) => r._measurement == "qc_all_duration_seconds")
    |> prometheus.histogramQuantile(quantile: 0.99, metricVersion: 1)

Was this page helpful?

Thank you for your feedback!


The future of Flux

Flux is going into maintenance mode. You can continue using it as you currently are without any changes to your code.

Read more

InfluxDB v3 enhancements and InfluxDB Clustered is now generally available

New capabilities, including faster query performance and management tooling advance the InfluxDB v3 product line. InfluxDB Clustered is now generally available.

InfluxDB v3 performance and features

The InfluxDB v3 product line has seen significant enhancements in query performance and has made new management tooling available. These enhancements include an operational dashboard to monitor the health of your InfluxDB cluster, single sign-on (SSO) support in InfluxDB Cloud Dedicated, and new management APIs for tokens and databases.

Learn about the new v3 enhancements


InfluxDB Clustered general availability

InfluxDB Clustered is now generally available and gives you the power of InfluxDB v3 in your self-managed stack.

Talk to us about InfluxDB Clustered