Repeatable Panel and query using $variable with \\ in result causing query to fail

I’m new here … hoping asking for this correctly.

I have a panel defined with for repeating across a variable, called url, with a set of values which includes IPs, and hostname so this:

192.168.1.1, 1.1.1.1, google.com

The panel is setup to repeat over the variable and it works fine until the query itself comes in. The very simple query looks like this:

ping_average_response_ms{url="$url"}

When the panel is using the query just above, all my panels says “No Data”.

When the query is using a hard coded value, like “1.1.1.1”, it works just fine.

I found the cause using the Inspect feature on the panel itself. When using hand coded value like “1.1.1.1” the query looks like this:

query:"ping_average_response_ms{url="1.1.1.1"}"

When the $url variable name is used in the query I get this for the query showing in Inspect:

query:"ping_average_response_ms{url="1\\.1\\.1\\.1"}"

Notice the double escaping/backslashing going on. That is what is causing my “No Data” issue.

I tried adding in “:raw” to the $url:raw but the variable with formatting specification in this query isn’t interpolated correctly. “:raw” simply becomes part of the query itself.

QUESTION: Is there a way to stop the backslashing all together when using variables in queries ?

I found a solution to this … what I believe is happening … regex is getting involved.

The solution was to basically change the repeating panel query to look like this:

ping_average_response_ms{url=~‘$url’}

Now my panels all work correctly.

1 Like