A work scenario that I can't cover currently is that I want to set a maintenance mode, meaning all alerts received from Prometheus to be ignored, I want to be able to set it through the UI for a given period until maintenance finish. One way to do it is manually to start covering each alert which in Prometheus-operator scenario is not sane, or I would lose a couple of hours. I can change config from secret to route all to null, but that is not practical as it requires multiple actions and is not good for on time or other user usage.
So I tried to use regex for key and value. Both set to .* .* regex. On preview I get all alerts covered, but when I click Create I get "Bad Request"? I couldn't find examples in internet and on official page which surprised me quite a lot.
3 Answers
If it's the only selector alertmanager (0.24) doesn't allow it to match an empty string.
So use prometheus=~".+" or severity=~".+" instead of prometheus=~".*", otherwise you get the error "silence invalid: at least one matcher must not match the empty string" from alertmanager.
With alertmanager 0.22 (perhaps even earlier?) the solution using regex is a bit less obvious as there is no longer any checkbox to tick for using a regex.
Instead, you must use Name="Value"
for an equality check and Name=~"RegEx.*"
if you want to use a regular expression. So you must use the =~
operator.
What about Name = "prometheus", Value = ".*". That is something that worked for me.
An alternative can be Name = "severity", Value = ".*" also.
-
thank you, your answer made me realize I didn't test key alertname with value .*, which works as well as the options you have covered, thanks a lot. It looks like request with any key is not acceptable to the api. Jun 23, 2020 at 7:47