bad matcher format when the filter param contains a leading '{' and a trailing '}'
What did you do?
I upgraded Alertmanager from 0.21.0 to 0.23.0.
What did you expect to see?
http://localhost:9093/api/v2/silences?filter={alertname=%22MyAlert%22} should return a list of filtered silences.
What did you see instead? Under which circumstances?
It returns "bad matcher format: {alertname=\"MyAlert\"}"
Environment
-
System information:
Linux 3.13.0-132-generic x86_64
-
Alertmanager version:
alertmanager, version 0.23.0 (branch: HEAD, revision: 61046b17771a57cfd4c4a51be370ab930a4d7d54) build user: root@e21a959be8d2 build date: 20210825-10:48:55 go version: go1.16.7 platform: linux/amd64
I forgot to say that if I remove the leading and trailing {} it works, but the doc says:
A leading '{' and/or a trailing '}' is optional and will be trimmed before further parsing.
This discrepancy comes from https://github.com/prometheus/alertmanager/blob/e3fb99cc2d24330fdb81aa1d466c19b3de328b5b/api/v2/api.go - ParseMatcher is used to parse each individual filter arg (which doesn't strip braces), rather than ParseMatchers which does. FWIW the Swagger API documentation doesn't specify (or at least, hints that args are individual Matchers rather than one Matchers), so I don't think there's anything incorrect with the docs, it's just misleading perhaps
Ok, but still the behavior changed by upgrading from 0.21.0 (maybe 0.22.0 too?) to 0.23.0.
Ok, but still the behavior changed by upgrading from 0.21.0 (maybe 0.22.0 too?) to 0.23.0.
The change is from 0.21 to 0.22. It's not recorded in CHANGELOG. https://github.com/prometheus/alertmanager/pull/2441
Agreed that the API documentation can be improved.
@waltherlee I guess this issue is resolved in v0.30?
Yes, I'm closing it