Created
May 26, 2020 08:12
-
-
Save wookietreiber/c55a07ae4a0233cc73fb351b9c6dd2b5 to your computer and use it in GitHub Desktop.
Prometheus/Alertmanager rules for business hour based inhibition (Germany/Saxony)
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 | |
interval: 60s | |
rules: | |
- record: daylight_saving_time | |
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: german_time | |
expr: | | |
time() + 3600 + 3600 * daylight_saving_time | |
- record: business_day | |
expr: | | |
vector(1) | |
and | |
day_of_week(german_time) > 0 | |
and | |
day_of_week(german_time) < 6 unless count(public_holiday) | |
- record: german_hour | |
expr: | | |
hour(german_time) | |
- record: business_hour | |
expr: | | |
vector(1) and german_hour >= 8 < 16 and business_day | |
- record: public_holiday | |
expr: | | |
vector(1) | |
and | |
day_of_month(german_time) == 1 | |
and | |
month(german_time) == 1 | |
labels: | |
name: Neujahrstag | |
- record: public_holiday | |
expr: | | |
vector(1) | |
and | |
day_of_month(german_time + 2 * 86400) == easter_day | |
and | |
month(german_time + 2 * 86400) == easter_month | |
labels: | |
name: Karfreitag | |
- record: public_holiday | |
expr: | | |
vector(1) | |
and | |
day_of_month(german_time - 86400) == easter_day | |
and | |
month(german_time - 86400) == easter_month | |
labels: | |
name: Ostermontag | |
- record: public_holiday | |
expr: | | |
vector(1) | |
and | |
day_of_month(german_time - 39 * 86400) == easter_day | |
and | |
month(german_time - 39 * 86400) == easter_month | |
labels: | |
name: Christi Himmelfahrt | |
- record: public_holiday | |
expr: | | |
vector(1) | |
and | |
day_of_month(german_time - 50 * 86400) == easter_day | |
and | |
month(german_time - 50 * 86400) == easter_month | |
labels: | |
name: Pfingstmontag | |
- record: public_holiday | |
expr: | | |
vector(1) | |
and | |
day_of_month(german_time) == 1 | |
and | |
month(german_time) == 5 | |
labels: | |
name: Tag der Arbeit | |
- record: public_holiday | |
expr: | | |
vector(1) | |
and | |
day_of_month(german_time) == 3 | |
and | |
month(german_time) == 10 | |
labels: | |
name: Tag der deutschen Einheit | |
- record: public_holiday | |
expr: | | |
vector(1) | |
and | |
day_of_month(german_time) == 31 | |
and | |
month(german_time) == 10 | |
labels: | |
name: Reformationstag | |
# TODO Buß- und Bettag | |
- record: public_holiday | |
expr: | | |
vector(1) | |
and | |
day_of_month(german_time) == 24 | |
and | |
month(german_time) == 12 | |
labels: | |
name: Heiligabend | |
- record: public_holiday | |
expr: | | |
vector(1) | |
and | |
day_of_month(german_time) == 25 | |
and | |
month(german_time) == 12 | |
labels: | |
name: Erster Weihnachtsfeiertag | |
- record: public_holiday | |
expr: | | |
vector(1) | |
and | |
day_of_month(german_time) == 26 | |
and | |
month(german_time) == 12 | |
labels: | |
name: Zweiter Weihnachtsfeiertag | |
- record: public_holiday | |
expr: | | |
vector(1) | |
and | |
day_of_month(german_time) == 31 | |
and | |
month(german_time) == 12 | |
labels: | |
name: Silvester | |
- alert: not_business_hour | |
expr: absent(business_hour) | |
labels: | |
time_window: always | |
- name: Easter Meeus/Jones/Butcher Algorithm | |
interval: 60s | |
rules: | |
- record: easter_y | |
expr: | | |
year(german_time) | |
- record: easter_a | |
expr: | | |
easter_y % 19 | |
- record: easter_b | |
expr: | | |
floor(easter_y / 100) | |
- record: easter_c | |
expr: | | |
easter_y % 100 | |
- record: easter_d | |
expr: | | |
floor(easter_b / 4) | |
- record: easter_e | |
expr: | | |
easter_b % 4 | |
- record: easter_f | |
expr: | | |
floor((easter_b + 8) / 25) | |
- record: easter_g | |
expr: | | |
floor((easter_b - easter_f + 1) / 3) | |
- record: easter_h | |
expr: | | |
(19 * easter_a + easter_b - easter_d - easter_g + 15) % 30 | |
- record: easter_i | |
expr: | | |
floor(easter_c / 4) | |
- record: easter_k | |
expr: | | |
easter_c % 4 | |
- record: easter_l | |
expr: | | |
(32 + 2 * easter_e + 2 * easter_i - easter_h - easter_k) % 7 | |
- record: easter_m | |
expr: | | |
floor((easter_a + 11 * easter_h + 22 * easter_l) / 451) | |
- record: easter_month | |
expr: | | |
floor((easter_h + easter_l - 7 * easter_m + 114) / 31) | |
- record: easter_day | |
expr: | | |
((easter_h + easter_l - 7 * easter_m + 114) % 31) + 1 | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment