Grafanano signalmediumCluster of 11 signals
Card #3394 · Grafana

Incorrect escaping of regex and special characters in template variables

Users are experiencing issues where template variables containing regex or special characters are automatically escaped, turning them into literal matches. This prevents the intended regular expression logic from working in queries and panels across various data sources.

GrafanaUpdated 1d ago0.20
Pain score
0.20/ 1.00 · weighted product of four components
Reach1.00
distinct authors (log-normalized)
Recency1.00
freshness decay, half-life months
Engagement0.95
upvotes + comments, normalized
Monetization0.25
willingness-to-pay cues in evidence
§ Evidence — 4 verified quotes
In that case, the parenthesis and pipe characters are escaped and the regexp no longer works because it becomes a literal match.
Forum·@voiprodrigo··source ↗
When I look in inspector whole variable is escaped, I’ll give example, for constant variable query_var value: hostname.keyword: host-02 In query inspector I get query.data : "query":"hostname.keyword\\:\\\"host\\-02\\\""
Forum·@user1509··source ↗
The value sent in the http API call to Prometheus replaces the stack=~"$stack" with stack%3D~%22.%22 (Note the missing escape value for + ).
Forum·@sujitvp··source ↗
There is a feature request to disable escaping.
Forum·@torkel··source ↗

Comments are a Pro feature — join the conversation, share what you've shipped, hear what others are building.

Upgrade to Pro