简体   繁体   中英

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.

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]))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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