Forward Slashes within tag keys causing problems with Regexp variables

Hej Community,

I’ve got a problem with forward slashes within the tag key of a query.
I do have a variable (request) which loads all request names and want to use the picked value in my queries.

SELECT count(“responseTime”) FROM “requestsRaw” WHERE (“requestName” =~ /^$request$/) AND $timeFilter

When I use the “query helper” - the one where you can click your query together - it work’s.
The query inspector shows me this:

SELECT count(“responseTime”) FROM “requestsRaw” WHERE (“requestName” =~ /^https://www.something.de/else.html$/)

As you can see, the forward slashes get escaped automatically. But I need to write my own requests without the easy query builder. If I do so, the query inspector show me this one.

SELECT count(“responseTime”) FROM “requestsRaw” WHERE (“requestName” =~ /^https://www.something.de/else.html$/)

This (obviously) fails with the following reason: error parsing query: found $, expected ) at line 1, char 120

How can I handle this?

Greetings from Berlin,
Stephan

Did you fix this? Lots of issues in the Grafana GitHub repo about this. For example:

Hej daniellee,

sadly I was not able to fix this.
At the moment I can only use the “easy query builder” but I really hope the grafana dev’s will fix this. :slight_smile:

The problem is that in raw mode, it is harder for Grafana to know the context and how it should be escaped. So you have to do some extra work yourself (like adding the extra brackets). We haven’t got a PR for this so I don’t think it so easy to fix and the core team is not planning to work on this right now.

Thanks for the fast response.
What do you mean by “adding the extra brackets”?

From the issue linked above:

In case anyone comes across this issue, an easy temporary fix is to put the brackets in manually when in raw mode, e.g. =~ /^($myvariable)$/