Escaping a $ (dollar sign) so it doesn't get treated as a variable

Using grafana v7.5.15 (the docker image), I’m looking for a way to escape a $ so it doesn’t get interpreted as a template variable.

I’ve tried:

  • \$ ← gets passed through as is
  • $$ ← gets passed through as is
  • \\$ ← gets passed through as is

but they don’t do what I want (pass through the string $1 but without grafana attempting to interpolate it).

Here’s an example prometheus query:


Right now grafana treats $1 as a variable replacement, but fortunately does nothing since the 1 variable doesn’t exist. But we have more complex use cases and I’d like to try and avoid this in the future.

1 Like

do you think you could try and replicate this on our public sandbox, :pray:

I might suggest upgrading to at least Grafana 8, as we aren’t really supporting v7 anymore

1 Like

granted, the problem might still exist :person_shrugging:

1 Like

Can do; I tried on the template variable dashboard.


## Escape a $?



Escape a $?

test.1, test2
$test.1, test2
\test.1, test2
\\test.1, test2


(removing the {} made no difference)

Desired output:


Running into the same problem with Grafana 8.3.6. Need to figure out how to escape the capture group reference.

1 Like