Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
806 views
in Technique[技术] by (71.8m points)

monitoring - 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?

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

What about the following query?

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...