- Implement the defined alerting conditions
- Set the following rule in the alerts:
vector(1) and on() business_hour
Forked from roidelapluie/gist:8c67e9c8fb18b310a4a90cb92a23056b
Last active
October 11, 2022 17:14
-
-
Save hartfordfive/4435bc530442719bf02fdab34e32d353 to your computer and use it in GitHub Desktop.
Prometheus alert on business days
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
groups: | |
- name: datetime | |
rules: | |
- record: daily_saving_time_belgium | |
expr: | | |
(vector(0) and (month() < 3 or month() > 10)) | |
or | |
(vector(1) and (month() > 3 and month() < 10)) | |
or | |
( | |
( | |
(month() %2 and (day_of_month() - day_of_week() > (30 + +month() % 2 - 7)) and day_of_week() > 0) | |
or | |
-1*month()%2+1 and (day_of_month() - day_of_week() <= (30 + month() % 2 - 7)) | |
) | |
) | |
or | |
(vector(1) and ((month()==10 and hour() < 1) or (month()==3 and hour() > 0))) | |
or | |
vector(0) | |
- record: belgium_localtime | |
expr: | | |
time() + 3600 + 3600 * daily_saving_time_belgium | |
- record: business_day | |
expr: | | |
vector(1) and day_of_week(belgium_localtime) > 0 and day_of_week(belgium_localtime) < 6 unless count(public_holiday) | |
- record: belgium_hour | |
expr: | | |
hour(belgium_localtime) | |
- record: business_hour | |
expr: | | |
vector(1) and belgium_hour >= 8 < 18 and business_day | |
- record: public_holiday | |
expr: | | |
vector(1) and day_of_month(belgium_localtime) == 1 and month(belgium_localtime) == 1 | |
labels: | |
name: jour de lan | |
- record: public_holiday | |
expr: | | |
vector(1) and day_of_month(belgium_localtime) == 1 and month(belgium_localtime) == 5 | |
labels: | |
name: fete du travail | |
- record: public_holiday | |
expr: | | |
vector(1) and day_of_month(belgium_localtime) == 21 and month(belgium_localtime) == 7 | |
labels: | |
name: fete nationale | |
- record: public_holiday | |
expr: | | |
vector(1) and day_of_month(belgium_localtime) == 15 and month(belgium_localtime) == 8 | |
labels: | |
name: assomption | |
- record: public_holiday | |
expr: | | |
vector(1) and day_of_month(belgium_localtime) == 1 and month(belgium_localtime) == 11 | |
labels: | |
name: toussaint | |
- record: public_holiday | |
expr: | | |
vector(1) and day_of_month(belgium_localtime) == 11 and month(belgium_localtime) == 11 | |
labels: | |
name: armistice de 1918 | |
- record: public_holiday | |
expr: | | |
vector(1) and day_of_month(belgium_localtime) == 25 and month(belgium_localtime) == 12 | |
labels: | |
name: noel | |
- record: public_holiday | |
expr: | | |
vector(1) and day_of_month(belgium_localtime) == 22 and month(belgium_localtime) == 4 and year(belgium_localtime) == 2019 | |
labels: | |
name: lundi de paques | |
- record: public_holiday | |
expr: | | |
vector(1) and day_of_month(belgium_localtime) == 30 and month(belgium_localtime) == 5 and year(belgium_localtime) == 2019 | |
labels: | |
name: ascension | |
- record: public_holiday | |
expr: | | |
vector(1) and day_of_month(belgium_localtime) == 10 and month(belgium_localtime) == 6 and year(belgium_localtime) == 2019 | |
labels: | |
name: pentecote | |
- alert: It is time to put 2020 legal holidays in prometheus | |
for: 7d | |
labels: | |
alertid: MON-0000 | |
priority: P5 | |
repeat_interval: 24h | |
recipient: monitoring/circuit | |
send_resolved: no | |
env: prod | |
title: Business Days | |
annotations: | |
description: It is time to put 2020 legal holidays in prometheus | |
action: Update templates/rules/businesshours.yml.j2 in the prometheus rules (Easter Monday, Ascension Day, Whit Monday). | |
expr: | | |
month() > 6 and year() == 2019 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment