Outbreak Labs

I can do anything I want to. And so can you.

Escaping Grafana Variables

I was parameterizing a Prometheus query in a Grafana dashboard like I've done many times before:


Only this time it didn't work. I hard-coded a sample value for each parameter and discovered it was the quantile variable, which has decimal values like 0.5 that was causing the query to return no results. Using the Query Inspector, I could see that the query being sent to Prometheus looked like:


As it turns out, Grafana escapes the variables as though they were going to be used in a regular expression. This happened to be the first time I've used a variable with a period in it, so I hadn't learned of this behavior until now. It turns out that you can use the format ${variable:raw} to get it to not do that. I replaced my query with this:


And it worked perfectly.

Comments are closed