prometheus - 如何查询大于值的普罗米修斯数据但包含系列向量中的所有数据?

标签 prometheus promql

我觉得这张图说明了一切

enter image description here

我想在 Prometheus 中查询一个值大于 .5 的系列,但在系列中包含较低的值,以便图表完整。 这些是 Gauge 指标,范围从 0-1(十进制百分比/比率) 我希望图表中的所有线条都完整。 当前查询

avg_over_time((failure_percentage > .5)[10m:])

我尝试过自连接和分组,但都没有成功。

最佳答案

在 prometheus slack 上的一些人的帮助下,我使用一种连接 hack 解决了这个问题

avg_over_time(failure_percentage[10m]) * ( (failure_percentage > 0.5) ^0 )

用户 viq 的原始评论(完整的上下文和解释)

I wonder.... a drity trick that comes to mind is something like

 metric * ( (metric > 0.5) ^ 0)

Since for multiplication to work both sides need to exactly match on labels, so you'll get only the results that match what's on the right, right (I think) should give you only results that match the condition, and ^0 should make the value always be 1, so you're getting in effect metric * 1 maaaaybe, untested

关于prometheus - 如何查询大于值的普罗米修斯数据但包含系列向量中的所有数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63397015/

相关文章:

prometheus - 使用prometheus数据源显示grafana的每日消耗

prometheus - 获取一段时间内的请求总数

prometheus - 如何在 Prometheus 查询中对标签进行分组?

kubernetes - K8S - 无法通过 - alertmanager 查看警报

go - 在 Go 模板中对 Alertmanager 电子邮件模板进行排序

kubernetes - cAdvisor Prometheus container_cpu_load_average_10s 有两个值

prometheus - 普罗米修斯中的速率函数是否真的给出了一段时间内的平均值?

kubernetes - 在 Kubernetes 中注册多个自定义指标 API

node.js - prom-client 在 NodeJS 应用程序中返回默认指标的空对象

Prometheus:如何使用probe_http_duration_seconds从黑盒导出器创建SLI/SLO?