PromQL提示“指标可能不是计数器”存疑,是否需关注?
问题:PromQL查询出现指标类型误判提示的原因及是否需要关注
我使用以下PromQL查询语句:
avg by (instance)(rate(fusion:node_cpu_seconds_total:foo{mode="steal"}[5m])) * 100
能正常获取大量数据,但查询后出现如下提示信息:
{ "infos": [ "PromQL info: metric might not be a counter, name does not end in _total/_sum/_count/_bucket: \"fusion:node_cpu_seconds_total:foo\" (1:25)", "PromQL info: metric might not be a counter, name does not end in _total/_sum/_count/_bucket: \"fusion:node_cpu_seconds_total:foo\" (1:27)" ], }
我对此感到困惑,因为指标名称fusion:node_cpu_seconds_total:foo确实以_total结尾,且我多次使用该格式。请问这是需要关注的真实问题吗?
回答:
- 这是PromQL语法检查工具的误判,不需要关注。
- 误判原因是检查逻辑可能仅做了简单的末尾字符匹配,你的指标名称带有冒号分隔的后缀
:foo,导致检查逻辑误以为指标不是以_total结尾。实际上指标核心部分node_cpu_seconds_total符合counter的命名规范,且rate()函数能正常处理数据,说明该指标确实是counter类型。 - 只要查询能正常返回有效数据,且指标的行为符合counter(单调递增)的特性,完全可以忽略这个提示。如果觉得提示干扰操作,可以查看你使用的查询工具设置,是否支持关闭这类语法检查提示。
内容的提问来源于stack exchange,提问作者Christian Bongiorno
相关产品推荐
相关产品推荐

