I think I see the problem now.  Each query term has to be a separate 
argument on the command line.

/opt/alertmanager/amtool --alertmanager.url="$ENDPOINT" alert query 
'alertname=DiskFull95 alertname=DiskFull95'   # does not work (no results; 
I think it treats this as alertname="DiskFull95 alertname=DiskFull95")
/opt/alertmanager/amtool --alertmanager.url="$ENDPOINT" alert query 
'alertname=DiskFull95' 'alertname=DiskFull95'  # works

Hence this works:

/opt/alertmanager/amtool --alertmanager.url="$ENDPOINT" alert query 
'alertname=~"Disk.+"' 'alertname=~".+Full.+"'

Since you put
    amtool ... alert query "$QUERY_STRING"
then the multi-word value is passed as a single argument.

Removing the quotes will allow the shell to split it and pass it as 
separate arguments:
    amtool ... alert query $QUERY_STRING

Tested:

QUERY_STRING='alertname=~"Disk.+" alertname=~".+Full.+"'
/opt/alertmanager/amtool --alertmanager.url="$ENDPOINT" alert query 
"$QUERY_STRING"  # does not work (error about unescaped quotes)
/opt/alertmanager/amtool --alertmanager.url="$ENDPOINT" alert query 
$QUERY_STRING  # works

On Thursday, 9 June 2022 at 12:16:19 UTC+1 Evelyn Pereira Souza wrote:

> On 06.06.22 19:11, Brian Candler wrote:
> > I suggest you try simply removing the double quotes from your amtool 
> query:
>
> Thanks. That solved the issue.
>
> 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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/prometheus-users/fb83d92a-0d53-4267-9e52-42d0ddec1cfen%40googlegroups.com.

Reply via email to