I'm trying to calculate easter sunday in PromQL using Gauss's Easter algorithm (I need to ignore some alert rules on public holidays).
I can calculate the day, but I'm having a problem with the month as I need something like an if/else expression. My recording rule easter_sunday_in_april returns 1 if eastern is in april and 0 if it is in march.
(How) can I express the following in PromQL?
if(easter_sunday_in_april > 0)
return 4
else
return 3
For the sake of completeness, I attach my recording rules here:
- record: a
expr: year(europe_time) % 4
- record: b
expr: year(europe_time) % 7
- record: c
expr: year(europe_time) % 19
- record: d
expr: (19*c + 24) % 30
- record: e
expr: (2*a + 4*b + 6*d + 5) % 7
- record: f
expr: floor((c + 11*d + 22*e)/451)
- record: easter_sunday_day_of_month_temp
expr: 22 + d +e - (7*f)
- record: easter_sunday_day_of_month_in_april
expr: easter_sunday_day_of_month_temp > bool 31
- record: easter_sunday_day_of_month
expr: easter_sunday_day_of_month_temp % 31