问题
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