This isn't promQL, although it's similar. It appears that amtool isn't 
happy with matchers that have two conditions with double quotes:

# /opt/alertmanager/amtool --alertmanager.url="$ENDPOINT" alert query 
'foo=~"bar" baz=~"qux"'
amtool: error: [GET /alerts][400] getAlertsBadRequest  matcher value 
contains unescaped double quote: foo=~"bar" baz=~"qux"

I suggest you try simply removing the double quotes from your amtool query:
QUERY_STRING='instance=~".+rem-prod.+" team="OMNR2"'
=>
QUERY_STRING='instance=~.+rem-prod.+ team=OMNR2'

Ref:
https://manpages.debian.org/testing/prometheus-alertmanager/amtool.1.en.html
https://prometheus.io/docs/alerting/latest/configuration/#matcher

On Monday, 6 June 2022 at 17:11:27 UTC+1 Evelyn Pereira Souza wrote:

> Hi
>
> I get this error with "amtool"
>
> amtool: error: [GET /alerts][400] getAlertsBadRequest matcher value 
> contains unescaped double quote: instance=~".+rem-prod.+" team="OMNR2"
>
> This the relevant snippet
>
> QUERY_STRING='instance=~".+rem-prod.+" team="OMNR2"'
>
>
> COUNTER=0
> until [[ -z $ALERTS ]]
> do
> ALERTS=$("${WORKSPACE}"/amtool --tls.insecure.skip.verify 
> --alertmanager.url="$ENDPOINT" -o extended alert query "$QUERY_STRING" | 
> grep -w active)
> [[ $COUNTER -gt 600 ]] && echo "(..)
> done
>
> kind regards
> Evelyn
>

-- 
You received this message because you are subscribed to the Google Groups 
"Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to prometheus-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/prometheus-users/49783902-8dab-4a7d-8f4d-d6554a897c0cn%40googlegroups.com.

Reply via email to