简体   繁体   English

Prometheus 获得向上度量 0 的计数以发出警报

[英]Prometheus get count of up metric 0 for give alert

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.我在 Prometheus 上设置了警报,其中警报中有不同的作业。我想找出上周警报被触发的次数,给定作业名称。所以有一个警报名称“A”,并且有多个作业“ B","C","D" 在此之下,我想知道上周有多少次警报“A”因工作“B”而被解雇。

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?我想知道是否有其他方法可以实现相同的目标?

What about the following query?下面的查询呢?

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM