gpt4 book ai didi

monitoring - prometheus 将一个 NaN 值结果求和为 NaN。如何避免?

转载 作者:行者123 更新时间:2023-12-05 01:16:31 36 4
gpt4 key购买 nike

我在 prometheus 中有以下指标:它按秒计算 memcached 命令:

sum (irate (memcached_commands_total{instance="memcached-instance"}[5m])) by (command)

结果:

{command="delete"}  0
{command="flush"} 0
{command="get"} 62.733333333333334
{command="incr"} 0
{command="set"} 93.43333333333334
{command="touch"} NaN
{command="cas"} 0
{command="decr"} 0

我想按秒计算命令(不同命令没有单独的速率)。我试过以下公式:

sum (irate (memcached_commands_total{instance="memcached-instance"}[5m]))

但结果是:

{}  NaN

我预计大约是 155,但它是 NaN。我想这是 command="touch"的罪魁祸首。可以从总和中排除 NaN 吗?

最佳答案

我想通了:

sum (irate (memcached_commands_total{instance="memcached-instance"}[5m]) > 0)

返回正确的数字。 >0 就可以了。

关于monitoring - prometheus 将一个 NaN 值结果求和为 NaN。如何避免?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53430836/

36 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com