PromQL Regex and the left bracket [ character

549 views
Skip to first unread message

Patrick Mackey

unread,
Apr 21, 2021, 11:02:16 PM4/21/21
to Prometheus Users
Hi, all.

I'm trying to match the left bracket character '[' with a regex and seem to be hitting some issues. I've tried with the octal sequence \133 and the hex sequence \x5B but both return either false positive matches or the following error:

Error executing query: invalid parameter "query": 1:19: parse error: error parsing regexp: missing closing ]: `[.*)$`

I'm running 2.26.0 from Docker.

My query is variations of:
ifOperStatus{ifAlias=~"\133.*"}

Matching the right bracket ']' with \135 and \x5D works fine.

Any ideas?

Matthias Rampke

unread,
Apr 22, 2021, 4:13:25 AM4/22/21
to Patrick Mackey, Prometheus Users
Try using [[] (match any of the following characters: [): https://play.golang.org/p/ynvSW3lIHDY

/MR

--
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-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-users/083e9924-483c-4506-aba6-f35be725798an%40googlegroups.com.

Patrick Mackey

unread,
Apr 22, 2021, 4:35:25 PM4/22/21
to Prometheus Users
Yes, that works. Thanks, Matthias!
Reply all
Reply to author
Forward
0 new messages