[英]How to count over threshold metrics from range vector in PromQL (Prometheus)
我定義了它可以查詢為標量的latency
指標,如下所示:
latency{name="Controller/products/show",percentiles="95"} 0.9935112
然后,我做了查詢。 輸出是一個范圍向量。
latency{name="Controller/products/show",percentiles="95"}[10m]
輸出:
element:
latency{name="Controller/products/show",percentiles="95"}
value:
0.9429009 @1584497778.164
0.9150374 @1584497838.164
0.9085548 @1584497898.164
0.9006939 @1584497958.164
0.9390876 @1584498018.164
0.9593425 @1584498138.164
0.96289706 @1584498198.164
0.98113775 @1584498258.164
0.9935112 @1584498318.164
我想從矢量范圍值中計算超過0.95
值。
例如,從上述矢量范圍值中得到4
。
有人有解決方案嗎?
Prometheus 子查詢可用於此任務:
count_over_time((latency{name="Controller/products/show",percentiles="95"} > 0.95)[10m:50s])
請注意,冒號后的step
值(在上面的示例中為50s
)必須小於所選指標的刮取間隔,因為 Prometheus 在常規點評估括號內的查詢,它們之間具有配置的step
間隔。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.