Reputation: 1
I am trying to generate a Prometheus alert where Prometheus will scrape data every 5 mins and will send an alert every 1 hr is the expression value is greater than 0. I am not able to generate an alert every 1hr. Any help on this? scrape interval is 5m and the eval interval is 1m pasting the alert code below:
- name:test
rules:
- alert: test alert
expr: test{instance="XXXX.XXX", job="test"} > 0
#for: 2m
labels:
severity: CRITICAL
applicationId: "{{$labels.application}}"
annotations:
description: "{{ $labels.environment }}: instance {{ $labels.instance }} has been down, number of messages: {{ $value }}"
summary: "{{ $labels.environment }}: instance {{ $labels.instance }} has been down, number of messages: {{ $value }}"
Upvotes: 0
Views: 2352
Reputation: 22311
If you want to receive the alert as soon as the problem happens and be remembered every hour if the issue still happens, than you must not use the Prometheus "for" clause and use the Alertmanager "repeat_interval" one, to specify how long to wait before sending a notification again if it has already been sent.
If you want to wait for 1h to receive the first alert, so you need to use the Prometheus "for" clause to specify the time (1h) you want to wait.
See more info about the Prometheus "for" clause here, and more info about the Alertmanager "repeat_interval" here.
Upvotes: 2