普罗米修斯获得指标 0 的计数以发出警报 [英] Prometheus get count of up metric 0 for give alert

查看:90
本文介绍了普罗米修斯获得指标 0 的计数以发出警报的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Prometheus 上设置了警报,其中警报中有不同的作业.我想知道在给定作业名称的情况下上周触发了多少次警报.所以有一个警报名称A"并且有多个作业B"、C"、D"在此之下,我想知道警报A"有多少次?因工作B"被解雇上周.

I have alerts setup on Prometheus where there are different jobs in the alert.I want to find how many times the alert was fired over last week, given the job name.So there is a alerts name "A" and there are multiple jobs "B","C","D" under that, I want to know how many times alert "A" was fired for job "B" in last week.

如果我使用以下表达式:

If I use following expression :

sum by(alertname) (changes(ALERTS_FOR_STATE[1w]))

它给了我上周发出的全部警报,但由于其中有多个工作,我无法弄清楚如何仅针对特定工作进行计数.

It gives me total alerts fired in last week but since there are multiple jobs in that, I am not able to figure out how to get count only for specific job.

我想知道是否有其他方法可以实现相同的目标?

I would like to know if there is some other way to achieve same thing?

推荐答案

下面的查询呢?

sum by (alertname, job) (changes(ALERTS_FOR_STATE[1w]))

这篇关于普罗米修斯获得指标 0 的计数以发出警报的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆