Please don't just say "it doesn't work". Say what happened. Did you see an error message? Did the alert fire when you were not expecting it, or not fire when you were expecting it?
Adding "if: ..." to an alerting rule shouldn't work - I cannot see that syntax anywhere in the
documentation. You need to put the logic into the expr: and you can debug your expr using the prometheus query GUI (*).
Adding parentheses might help. I suspect that
foo and on() bar or baz
will be parsed as
(foo and (on() bar)) or baz
which is not what you require.
Because you're using on() I think you're already aware that "and", "or" and "==" don't work the way that newcomers expect. To summarize:
foo : is a set of timeseries.
foo{bar="baz"} : is the same set of timeseries, filtered down to only those with label bar="baz".
foo{bar="baz"} == 1 : is the same set of timeseries, filtered down to only those with label bar="baz" and whose value is 1.
foo and bar : is the set of timeseries from foo, filtered to only those where bar exists with the exact same set of labels (but any value). Given that day_of_week() == 6 is a scalar value (6) it has no labels.
(*) You can test your expression in the PromQL browser like this: try selecting the graph view and scrolling out so you display 2 weeks.
up == 1 # ok
up == 1 and day_of_week() == 4 # no results
up == 1 and on() day_of_week() == 4 # works
up == 1 and on () day_of_week() == 4 or day_of_week() == 5 # unexpected: gives value 1 or value 5
up == 1 and on () (day_of_week() == 4 or day_of_week() == 5) # correct
I think this confirms that your problem is lack of parentheses.