Alertmanager 0.23 API get silences filter

1,126 views
Skip to first unread message

Guillaume DESBOIS

unread,
Sep 27, 2021, 11:16:51 AM9/27/21
to Prometheus Users
Hi,

In Alertmanager 0.21 the following api request works great : /api/v2/silences?filter="alertname=~Memory.*"

The filter on a label with a "like" (~) works !

But in alertmanager 0.23, the same query returns : "bad matcher format: \"alertname=~Memory.*\""

I've found that the syntax have changed and with an equal filter it's ok without the " " in the query  : /api/v2/silences?filter=alertname=MemoryHost

But if i add a ~ in the query like  /api/v2/silences?filter=alertname=~Memory.*  it returns "bad matcher format: \"alertname=~Memory.*\""

What is the syntax to get silences filter with a ~ ?

Thank you for your help

Brian Candler

unread,
Sep 27, 2021, 12:07:21 PM9/27/21
to Prometheus Users
Remove the outer double quotes for the =~ version as well.

It works for me.  For example, if I have a silence with
"matchers":[{"isEqual":true,"isRegex":true,"name":"instance","value":"r[1-8]"}, ...

then I can see it using either:

Barry

unread,
Jan 8, 2024, 9:14:07 AM1/8/24
to Prometheus Users
Since you received no replies to confirm and I'm seeing this issue myself...

removing the quotes doesn't seem to make any difference. am I wrong in thinking maybe your GET works because the silence is constructed with regex whereas silences returning "isRegex":false cannot be queried with regex?

Brian Candler

unread,
Jan 8, 2024, 9:26:01 AM1/8/24
to Prometheus Users
Please show the specific issue you're seeing: what the silence is, and what curl command line you're using to try to query it with.

Note: the "regex" attribute is not referring to the API filter, it's an attribute of the silence itself. That is, the silence uses a regex when matching alert labels to decide whether to silence them.
Reply all
Reply to author
Forward
0 new messages