Update sleep-peacefully.md

This commit is contained in:
Samuel Berthe 2023-04-12 21:03:32 +02:00 committed by GitHub
parent 603edb2536
commit 6c93417fea
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -18,67 +18,85 @@ Example:
```yml ```yml
# rules.yml # rules.yml
groups:
- name: timezones
rules:
- record: european_summer_time_offset
expr: |
(vector(1) and (month() > 3 and month() < 10))
or
(vector(1) and (month() == 3 and (day_of_month() - day_of_week()) >= 25) and absent((day_of_month() >= 25) and (day_of_week() == 0)))
or
(vector(1) and (month() == 10 and (day_of_month() - day_of_week()) < 25) and absent((day_of_month() >= 25) and (day_of_week() == 0)))
or
(vector(1) and ((month() == 10 and hour() < 1) or (month() == 3 and hour() > 0)) and ((day_of_month() >= 25) and (day_of_week() == 0)))
or
vector(0)
- record: is_european_summer_time - record: europe_london_time
expr: | expr: time() + 3600 * european_summer_time_offset
(vector(1) and (month() > 3 and month() < 10)) - record: europe_paris_time
or expr: time() + 3600 * (1 + european_summer_time_offset)
(vector(1) and (month() == 3 and (day_of_month() - day_of_week()) >= 25) and absent((day_of_month() >= 25) and (day_of_week() == 0)))
or
(vector(1) and (month() == 10 and (day_of_month() - day_of_week()) < 25) and absent((day_of_month() >= 25) and (day_of_week() == 0)))
or
(vector(1) and ((month() == 10 and hour() < 1) or (month() == 3 and hour() > 0)) and ((day_of_month() >= 25) and (day_of_week() == 0)))
or
vector(0)
- record: europe_london_time - record: europe_london_hour
expr: time() + 3600 * is_european_summer_time expr: hour(europe_london_time)
- record: europe_paris_time - record: europe_paris_hour
expr: time() + 3600 * (1 + is_european_summer_time) expr: hour(europe_paris_time)
- record: europe_london_hour - record: europe_london_weekday
expr: hour(europe_london_time) expr: 0 < day_of_week(europe_london_time) < 6
- record: europe_paris_hour - record: europe_paris_weekday
expr: hour(europe_paris_time) expr: 0 < day_of_week(europe_paris_time) < 6
# opposite
- record: not_europe_london_weekday
expr: absent(europe_london_weekday)
- record: not_europe_paris_weekday
expr: absent(europe_paris_weekday)
- record: europe_london_weekday - record: europe_london_daytime
expr: 0 < day_of_week(europe_london_time) < 6 expr: 9 < europe_london_hour < 18
- record: europe_paris_weekday - record: europe_paris_daytime
expr: 0 < day_of_week(europe_paris_time) < 6 expr: 9 < europe_paris_hour < 18
# opposite
- record: not_europe_london_daytime
expr: absent(europe_london_daytime)
- record: not_europe_paris_daytime
expr: absent(europe_paris_daytime)
- record: europe_london_daytime # new year's day / xmas / labor day / all saints' day / ...
expr: 8 < europe_london_hour < 18 - record: europe_french_public_holidays
- record: europe_paris_daytime expr: |
expr: 8 < europe_paris_hour < 18 (vector(1) and month(europe_paris_time) == 1 and day_of_month(europe_paris_time) == 1)
or
# new year's day / xmas / labor day / all saints' day / ... (vector(1) and month(europe_paris_time) == 12 and day_of_month(europe_paris_time) == 25)
- record: europe_french_public_holidays or
expr: | (vector(1) and month(europe_paris_time) == 5 and day_of_month(europe_paris_time) == 1)
(vector(1) and month(europe_paris_time) == 1 and day_of_month(europe_paris_time) == 1) or
or (vector(1) and month(europe_paris_time) == 11 and day_of_month(europe_paris_time) == 1)
(vector(1) and month(europe_paris_time) == 12 and day_of_month(europe_paris_time) == 25) or
or vector(0)
(vector(1) and month(europe_paris_time) == 5 and day_of_month(europe_paris_time) == 1) # opposite
or - record: not_europe_french_public_holidays
(vector(1) and month(europe_paris_time) == 11 and day_of_month(europe_paris_time) == 1) expr: absent(europe_french_public_holidays)
or
vector(0)
``` ```
```yml ```yml
# alerts.yml # alerts.yml
- alert: HighLoadQuietDuringWeekendAndNight groups:
expr: node_load5 > 10 and ON() (europe_london_weekday and europe_paris_weekday) - name: CPU Load
rules:
- alert: HighLoadQuietDuringWeekendAndNight
expr: node_load5 > 10 and ON() (europe_london_weekday and europe_paris_weekday)
- alert: HighLoadQuietDuringBackup - alert: HighLoadQuietDuringBackup
expr: node_load5 > 10 and ON() absent(hour() == 2) expr: node_load5 > 10 and ON() absent(hour() == 2)
- alert: HighLoad - alert: HighLoad
expr: | expr: |
node_load5 > 20 and ON() (europe_london_weekday and europe_paris_weekday) node_load5 > 20 and ON() (europe_london_weekday and europe_paris_weekday)
or or
node_load5 > 10 node_load5 > 10
``` ```
## Sources ## Sources