Thank you for the reply.
answers for above points-
1. i checked expression "up == 0" is firing rarely and all my targets are being scraped.
2. for not to get alerts every minutes, now i kept evaluation_interval as 5m
3. i have removed keep_firing_for as it is not suitable for my use case.
Updated:
I am using prometheus alerting for rabbitmq. Below is the configuration I am using.
prometheus.yml file
global:
scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
evaluation_interval: 5m # Evaluate rules every 15 seconds. The default is every 1 minute.
# scrape_timeout is set to the global default (10s).
alerting:
alertmanagers:
- static_configs:
- targets:
- ip:port
rule_files:
- "alerts_rules.yml"
scrape_configs:
- job_name: "prometheus"
static_configs:
- targets: ["ip:port"]
alerts_rules.yml file
groups:
- name: instance_alerts
rules:
- alert: "Instance Down"
expr: up == 0
for: 30s
# keep_firing_for: 30s
labels:
severity: "Critical"
annotations:
summary: "Endpoint {{ $labels.instance }} down"
description: "{{ $labels.instance }} of job {{ $labels.job }} has been down for more than 30 sec."
- name: rabbitmq_alerts
rules:
- alert: "Consumer down for last 1 min"
expr: rabbitmq_queue_consumers == 0
for: 30s
# keep_firing_for: 30s
labels:
severity: Critical
annotations:
summary: "shortify | '{{ $labels.queue }}' has no consumers"
description: "The queue '{{ $labels.queue }}' in vhost '{{ $labels.vhost }}' has zero consumers for more than 30 sec. Immediate attention is required."
- alert: "Total Messages > 10k in last 1 min"
expr: rabbitmq_queue_messages > 10000
for: 30s
# keep_firing_for: 30s
labels:
severity: Critical
annotations:
summary: "'{{ $labels.queue }}' has total '{{ $value }}' messages for more than 1 min."
description: |
Queue {{ $labels.queue }} in RabbitMQ has total {{ $value }} messages for more than 1 min.
Event if there is no data in queue, it sends me alerts. I have kept evaluation_interval: 5m ( Prometheus evaluates alert rules every 5 minutes) and for: 30s (Ensures the alert fires only if the condition persists for 30s).
I guess for is not working for me.
By the way i am not using alertmanager(https://github.com/prometheus/alertmanager/releases/latest/download/alertmanager-0.28.0.linux-amd64.tar.gz)
i am just using prometheus (https://github.com/prometheus/prometheus/releases/download/v3.1.0/prometheus-3.1.0.linux-amd64.tar.gz)
https://prometheus.io/download/
How can i solve this. Thank you in advance.
Thank you for the quick reply.
So, as i told you i am not using alertmanager. i am getting alerts based on config->
alerting:
alertmanagers:
- static_configs:
- targets:
- IP_ADDRESS_OF_EMAIL_APPLICATION:PORT
written in prometheus.yml file. below is the alert response (array of object) i am receiving from prometheus.
[
{
annotations: {
description: 'Queue QUEUE_NAME in RabbitMQ has total 1.110738e+06 messages\n' +
'for more than 1 minutes.\n',
summary: "RabbitMQ Queue 'QUEUE_NAME' has more than 10L messages"
},
endsAt: '2025-02-03T06:33:31.893Z',
startsAt: '2025-02-03T06:28:31.893Z',
generatorURL: 'http://helo-container-pr:9091/graph?g0.expr=rabbitmq_queue_messages+%3E+1e%2B06&g0.tab=1',
labels: {
alertname: 'Total Messages > 10L in last 1 min',
instance: 'IP_ADDRESS:15692',
job: 'rabbitmq-rcs',
queue: 'QUEUE_NAME',
severity: 'critical',
vhost: 'webhook'
}
}
]
If i keep evaluation_internal: 15s, it started triggering every minute.
I want alerts to be trigger after 5 min and only if condition is true.
> I want alerts to be trigger after 5 min and only if condition is true.
description: 'Queue QUEUE_NAME in RabbitMQ has total 1.110738e+06 messages\n' +
'for more than 1 minutes.\n',
summary: "RabbitMQ Queue 'QUEUE_NAME' has more than 10L messages"
As u can see in below imagesLast trigger was at 15:31:29And receive emails after that time also, which is for example 15:35, 15:37, etc.
1. when i keep evaluation_interval: 5m and for: 30s -> i get alerts every 5 min. (those alerts gets store in prometheus and triggers every 5 min, i mean even if condition is not matching, i still used to get alerts every 5min)
now i am changing config to below:-
evaluation_interval: 15s # on the rule group, or globally
for: 5m # on the individual alerting rule(s)
i will update you about this soon.
2. If you want a more readable string in the annotation, you can use {{ $value | humanize }}, but it will lose some precision.
This is serious concern for us. how to solve this?
one more imp thing,
why do i receive same {{ $value }} alerts again and again. In rabbitmq, it is possible to get different values, but same value not possible always. but i receive alerts having same value many times.
2. If you want a more readable string in the annotation, you can use {{ $value | humanize }}, but it will lose some precision.
This is serious concern for us. how to solve this?
with only this config:-
scrape_interval: 15s
evaluation_interval: 15s
And
for: 5m # in rules.
you can see image below,
there is an event at 18:11:54 having value 117. But i received total 13 alerts(emails) having value 117


Thanks for the reply
can you please help me what config should i use?
with this config:-
prometheus.yml
scrape_interval: 15s
evaluation_interval: 15s
And
alerts_rules.yml
for: 5m # in rules.
as per prometheus graph for my expression-
start time for expression condition matched 2025-03-12 15:24:47
end time for expression condition matched 2025-03-12 15:31.59
BUT
first alert receive at 2025-03-12 15:29:57
last alert receive at2025-03-12 15:47:12