Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/date/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Prometheus 当分子为空时,使用普罗米修斯计算成功率_Prometheus - Fatal编程技术网

Prometheus 当分子为空时,使用普罗米修斯计算成功率

Prometheus 当分子为空时,使用普罗米修斯计算成功率,prometheus,Prometheus,当我们想要计算成功率但没有成功的任务时,我们有很多用例,我们希望成功率为0,但没有 让我们以这些指标为例: http_requests_total{state="failure"} = 10 http_requests_total{state="succes"} - never happened so there is no value at all 我想计算成功率(在本例中为0)。执行部门: http_requests_total{state="success} / sum(http_re

当我们想要计算成功率但没有成功的任务时,我们有很多用例,我们希望成功率为0,但没有

让我们以这些指标为例:

http_requests_total{state="failure"} = 10

http_requests_total{state="succes"} - never happened so there is no value at all
我想计算成功率(在本例中为0)。执行部门:

http_requests_total{state="success} / sum(http_requests_total) ignoring (state)
不返回任何数据点

有什么建议吗?我做错了吗

试图执行:

(http_requests_total{state="success} or 0)/ sum(http_requests_total) ignoring (state)
但或操作员不工作


我希望输出为0,但它是“无数据点”

这并不是那么简单,这就是为什么不使用仅在发生事件时才显示的度量的原因之一

如果您不能在以后的阶段将任何数据处理为零成功率(例如,在Grafana中使用“null as zero”选项)
的版本似乎具有正确匹配的所有适当标签,可以是:

http_requests_total{state="success"} or
 label_replace(0 * sum without (state) (http_requests_total), "state", "success", "__name__", ".*")
此(ab)使用
label\u replace
合成元素,其中没有元素且看起来不漂亮