Prometheus get count of up metric 0 for give alert

核能气质少年 提交于 2021-01-29 06:02:51

问题


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?


回答1:


What about the following query?

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


来源:https://stackoverflow.com/questions/65617748/prometheus-get-count-of-up-metric-0-for-give-alert

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!