Skip to content

Instantly share code, notes, and snippets.

@roidelapluie
Created November 13, 2018 16:26
Show Gist options
  • Star 28 You must be signed in to star a gist
  • Fork 7 You must be signed in to fork a gist
  • Save roidelapluie/8c67e9c8fb18b310a4a90cb92a23056b to your computer and use it in GitHub Desktop.
Save roidelapluie/8c67e9c8fb18b310a4a90cb92a23056b to your computer and use it in GitHub Desktop.
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
@LeMyst
Copy link

LeMyst commented Feb 17, 2020

Merci, très pratique 👌
Myst~

@roidelapluie
Copy link
Author

@gevraud
Copy link

gevraud commented Aug 20, 2020

Hello,

Est-ce que cela est toujours a jour pour 2020 ?

Bàt

@roidelapluie
Copy link
Author

Le repo git est maintenant toujours à jour (pour la belgique)

@gevraud
Copy link

gevraud commented Aug 20, 2020

Impec.

Merci

@roidelapluie
Copy link
Author

(Le repo git calcule la date de paques.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment