【发布时间】:2016-12-13 21:06:35
【问题描述】:
在我的应用程序中,我为每个国家/地区的 websocket ping 时间设置了直方图,每个国家/地区一个直方图。在 Grafana 中,我通过以下查询获得了我最感兴趣的几个国家/地区的平均 ping 时间图表
rate(country_ping_sum{country=~"AU|NZ|CA|GB|US",instance="$instance"}[15m]) / rate(country_ping_count{country=~"AU|NZ|CA|GB|US",instance="$instance"}[15m])
这很好用。我得到了每个国家的图表。现在我想将所有其他国家/地区的平均值加到同一个图表中。
avg(rate(country_ping_sum{country!~"AU|NZ|CA|GB|US",instance="$instance"}[15m]) / rate(country_ping_count{country!~"AU|NZ|CA|GB|US",instance="$instance"}[15m]))
这失败了。当我在 Prometheus 控制台的 Prometheus 查询中尝试查询时,我得到一个 NaN 值。如果我采用相同的查询并删除 avg() 函数,那么我会得到每个匹配国家/地区的列表,有些有值,有些有 NaN。许多国家的总和和计数的比率均为 0。显然,对于这些特定国家/地区,这些除以 0 等于 NaN。
所以我的问题是,如何在传递给 avg() 之前过滤掉 NaN 值?
【问题讨论】:
-
avg(country_ping_sum{country!~"AU|NZ|CA|GB|US",instance="$instance"} > 0)。链接-kuricat.com/articles/…
标签: grafana prometheus