label_replace inverse matching

30 views
Skip to first unread message

Stevo Slavić

unread,
May 23, 2020, 8:25:41 AM5/23/20
to Prometheus Users
Hello Prometheus users,

Does label_replace regex support negative lookahead?

I tried using as last parameter "^((?!foo).)*$" but get the error:

Error executing query: invalid regular expression in label_replace(): ^((?!foo).)*$

Same for "^(?!foo).*$"

Kind regards,
Stevo Slavic.

Brian Brazil

unread,
May 23, 2020, 9:43:01 AM5/23/20
to Stevo Slavić, Prometheus Users
On Sat, 23 May 2020 at 13:25, Stevo Slavić <ssl...@gmail.com> wrote:
Hello Prometheus users,

Does label_replace regex support negative lookahead?

Prometheus uses Go's regexes which are RE2, and thus don't support negative lookahead. You can usually workaround by using negative regex matchers.

Brian
 

I tried using as last parameter "^((?!foo).)*$" but get the error:

Error executing query: invalid regular expression in label_replace(): ^((?!foo).)*$

Same for "^(?!foo).*$"

Kind regards,
Stevo Slavic.

--
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/5fb51c41-4ef6-47a0-b9a2-9b2da01bdd26%40googlegroups.com.


--
Reply all
Reply to author
Forward
0 new messages