首页 > 解决方案 > 用一个标签对所有计数器求和 - 普罗米修斯

问题描述

大家好,我有一个错误计数器,可以为我提供如下指标,我想获得过去 7 天内每个错误原因的总和。我试过使用增加,但似乎增加功能不支持by/without运算符,所以我得到的结果包括machine_type.

如何不包含machine_type在查询结果中?

{instance="localhost:8000", job="prometheus", reason="Some_reason", machine_type="gpu"}

这就是我尝试过 increase(error_count_total[24h]) 的结果是

{instance="localhost:8000", job="prometheus", reason="Some_reason", machine_type="gpu"}: 15
{instance="localhost:8000", job="prometheus", reason="Some_reason", machine_type="cpu"}: 10

我想得到

{instance="localhost:8000", job="prometheus", reason="Some_reason"}: 25

标签: prometheusmonitoringmetricspromql

解决方案


尝试以下查询:

sum without (machine_type) (increase(error_count_total[24h]))

推荐阅读