Open sinkingpoint opened 1 year ago
Looking at this a bit deeper, it might be a UI bug. Opening the silence page for a silence without the quotes sends a request to: http://localhost:9093/api/v2/alerts?filter=instance%3D~%22bar%22&silenced=true&inhibited=true&active=true
, whereas opening the silence page for the silence with quotes sends a request to http://localhost:9093/api/v2/alerts?silenced=true&inhibited=true&active=true
(without a filter
), but I don't know enough elm to confirm this
What did you do?
Created a silence with a regex matcher with a double quote in it
What did you expect to see?
The silence shouldn't match anything
What did you see instead? Under which circumstances?
The silence matches everything
Environment
System information:
Linux 5.15.49-linuxkit x86_64
Alertmanager version:
The default from prom/alertmanager:v0.25.0
Bit of a long form description for replication:
docker run -d -p 9093:9093 prom/alertmanager:v0.25.0
curl -XPOST localhost:9093/api/v2/alerts -H 'Content-Type: application/json' -d '[{"labels":{"instance":"foo"}}]'
curl -XPOST localhost:9093/api/v2/silences -H 'Content-Type: application/json' -d '{"comment":"foo", "createdBy": "cd@cloudflare", "startsAt":"2023-03-06T00:22:15Z", "endsAt":"2024-03-06T00:22:15Z", "matchers":[{"isRegex":true, "name":"instance", "value":"\"bar\""}]}'
Observe that the created silence matches the alert:
Note that the double quotes are included in the regex erroneously - I got confused because the Web UI enforces the use of quotes around matchers and strips them, but the API does not do this. But either way, including quotes in the regex should not match anything that doesn't also have quotes in it.