Skip to content

Instantly share code, notes, and snippets.

@sathed
Last active October 4, 2019 15:36
Show Gist options
  • Save sathed/0396153457b6bcca5287479d83648c2f to your computer and use it in GitHub Desktop.
Save sathed/0396153457b6bcca5287479d83648c2f to your computer and use it in GitHub Desktop.
Timezone Offset for Prometheus (Mountain Time/US)
# The following will create an DST offset in the US. Obviously, if you're in an area that doesn't
# observe DST (Arizona, etc.), this doesn't apply. To tweak it for your specific TZ, change the last value to
# your UTC offset during the summer months. A chart is below. I threw this together pretty quick,
# so it may need a bit of tweaking. It's a modified version of the PromQL found on Medium, here:
# https://link.medium.com/vcfRGNuYv0
# 4 - Eastern
# 5 - Central
# 6 - Mountain
# 7 - Pacific
# 8 - Alaska
# 9 - Hawaii
((vector(0) and (month() > 3 and month() < 11))
or
(vector(0) and (month() == 3 and (day_of_month() - day_of_week()) >= 6) and absent((day_of_month() >= 6) and (day_of_week() == 0)))
or
(vector(0) and (month() == 11 and (day_of_month() - day_of_week()) < 1) and absent((day_of_month() >= 1) and (day_of_week() == 0)))
or
(vector(0) and ((month() == 11 and hour() < 2) or (month() == 3 and hour() > 1)) and ((day_of_month() >= 7) and (day_of_week() == 0)))
or
vector(1)) + 6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment