Grafana 4.6.3 Disappearing template variables

I’m building a template up and if I edit the final template variable, my query is set correctly (in query inspector down below):

q:"SELECT mean("mean") FROM "development.hnypots.hnypots.controllers.attacks_index.get.200.view""

— however at the next auto-refresh or if I change a variable, it gets changed to:

q:"SELECT mean("value") FROM /^0$/ WHERE time >= now() - 1h GROUP BY time(2s) fill(null)"

any ideas on where to debug this? Here is an example gif of the behavior:


I think you can skip the third hidden template variable and us that query (measurement) in the panel query instead.


I can only get the query to stay if I stay in the non-wizardy query builder (where its just a text box) - if I revert back it changes and doesn’t work anymore. And the query itself does work if I go to the influx console and run it - I get a value back. However when Grafana is running the same query it returns nothing / nothing gets graphed.


The third template variable you’ve defined are using a constant value of "SELECT mean(“mean”) FROM "development.hnypots.hnypots.controllers.[[controller]][[action]].get.200.view". Please change the template variable to only set [[controller]][[action]].

Then in your query select from the measurement in the following way:

SELECT mean("mean") FROM "development.hnypots.hnypots.controllers.[[template_variable]].get.200.view" ...

Or skip the third template variable and right the query like this:

SELECT mean("mean") FROM "development.hnypots.hnypots.controllers.[[controller]]_[[action]].get.200.view" ...

Please see this example. It uses template variables to filter, but in your case you want to add template variable selection to selection of measurement.


I think I got it solved with some more fiddling - I had to set that last variable to be a “Constant” and then use the format you suggested so it would go in properly! Thanks @mefraimsson