Last active
October 30, 2023 04:55
-
-
Save object-Object/4bac834928fecea56082d7018d6d4f4a to your computer and use it in GitHub Desktop.
PromQL query to return the current Eastern Time Zone UTC offset.
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
# PromQL query to return the current Eastern Time Zone UTC offset. | |
# based on https://medium.com/@tom.fawcett/time-of-day-based-notifications-with-prometheus-and-alertmanager-1bf7a23b7695 | |
# https://en.wikipedia.org/wiki/Eastern_Time_Zone | |
# EDT (summer): UTC-4 | |
# EST (winter): UTC-5 | |
# second Sunday in March: 02:00 EST -> 03:00 EDT (07:00 UTC) | |
# first Sunday in November: 02:00 EDT -> 01:00 EST (06:00 UTC) | |
# after March and before November | |
( | |
vector(-4) # EDT | |
and month() > 3 | |
and month() < 11 | |
) | |
# after the second Sunday in March | |
or ( | |
vector(-4) # EDT | |
and month() == 3 | |
# after the week that starts with Sunday the 7th | |
# ie. after the first week of the month | |
# so the first place this line would be true is Sunday the 8th | |
and (day_of_month() - day_of_week()) > 7 | |
# but don't include the second Sunday in the month | |
and absent( | |
day_of_month() > 7 and day_of_month() <= 14 | |
and day_of_week() == 0 | |
) | |
) | |
# at least 07:00 UTC on the second Sunday in March | |
or ( | |
vector(-4) # EDT | |
and month() == 3 | |
and day_of_month() > 7 and day_of_month() <= 14 | |
and day_of_week() == 0 | |
and hour() >= 7 | |
) | |
# before the first Sunday in November | |
or ( | |
vector(-4) # EDT | |
and month() == 11 | |
and (day_of_month() - day_of_week()) < 1 | |
) | |
# before 06:00 UTC on the first Sunday in November | |
or ( | |
vector(-4) # EDT | |
and month() == 11 | |
and day_of_month() <= 7 | |
and day_of_week() == 0 | |
and hour() < 6 | |
) | |
# otherwise | |
or vector(-5) # EST |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment