prometheus.histogramQuantile() 函数
prometheus.histogramQuantile()
是实验性的,并且随时可能更改。
prometheus.histogramQuantile()
计算一组 Prometheus 直方图值的分位数。
此函数支持 prometheus.scrape()
、Telegraf promtheus
输入插件和 InfluxDB 抓取器(在 InfluxDB OSS 中可用)使用的 Prometheus 指标解析格式。
函数类型签名
(<-tables: stream[{B with le: D, _field: C}], quantile: float, ?metricVersion: A, ?onNonmonotonic: string) => stream[E] where A: Equatable, C: Equatable, E: Record
有关更多信息,请参阅函数类型签名。
参数
quantile
(必需) 要计算的分位数。必须是介于 0.0 和 1.0 之间的浮点值。
metricVersion
Prometheus 指标解析格式,用于解析查询的 Prometheus 数据。可用版本为 1
和 2
。默认为 2
。
tables
输入数据。默认为管道转发数据 (<-
)。
onNonmonotonic
描述当计数按上限排序时非单调递增时的行为。默认为 error
。
支持的值:
- error: 产生错误。
- force: 强制箱计数单调递增,方法是添加到每个箱,使其等于下一个较小的箱。
- drop: 当遇到非单调表时,不产生输出。
示例
计算 Prometheus 直方图的 0.99 分位数
import "experimental/prometheus"
prometheus.scrape(url: "http://localhost:8086/metrics")
|> filter(fn: (r) => r._measurement == "prometheus")
|> filter(fn: (r) => r._field == "qc_all_duration_seconds")
|> prometheus.histogramQuantile(quantile: 0.99)
计算使用指标版本 1 解析的 Prometheus 直方图的 0.99 分位数
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)
此页是否对您有帮助?
感谢您的反馈!