文档文档

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!


Flux 的未来

Flux 即将进入维护模式。您可以像目前一样继续使用它,无需更改您的代码。

阅读更多

InfluxDB 3 开源版现已推出公共 Alpha 版

InfluxDB 3 开源版现已推出 Alpha 测试版,根据 MIT 或 Apache 2 许可协议获得许可。

我们正在发布两个产品作为 alpha 的一部分。

InfluxDB 3 Core 是我们新的开源产品。它是用于时间序列和事件数据的最新数据引擎。 InfluxDB 3 Enterprise 是一个商业版本,建立在 Core 的基础上,增加了历史查询功能、读取副本、高可用性、可扩展性和细粒度的安全性。

有关如何开始使用的更多信息,请查看