You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
PromQL regex classes \d, \w, \s, \b match Unicode; Prometheus matches ASCII only #981
Two series of x: instance="café" and instance="cafe". In an independent review probe on the branch of #974's PR, the executor's label matchers gave:
Matcher
Executor (Rust regex)
Prometheus (Go RE2)
x{instance=~"\\w+"}
both series
only cafe
x{instance=~"\\d+"} with instance="١٢" (Arabic-Indic digits)
matches
no match
Why it happens
Rust's regex crate makes the Perl classes \d, \w, \s and the word boundary \b Unicode-aware by default.
Go's RE2, which Prometheus uses, defines them over ASCII only.
The PromQL parser (promql-parser) and the executor (expressions::promql_anchored_regex) both compile patterns with Rust's regex, so the system is consistent with itself but not with Prometheus.
(?i), the anchoring ^(?s:…)$ and Go-style literal braces (/api/{id}) already match Prometheus.
Proposal
Compile label patterns with these classes made ASCII-only, so they match Go's RE2:
either rewrite \d, \w, \s, \b (and their negations) to (?-u:\d) and so on;
or build the regex with regex::RegexBuilder and unicode(false) where the pattern needs no other Unicode feature.
Do this in promql_anchored_regex, the one place the executor compiles PromQL patterns. Check whether the parser's matcher, used at planning time, needs the same change.
Scope and acceptance
Scope: executor label matchers and label_replace patterns.
Activity