I’m looking for a way to make modular queries in order to reduce writing the same WHERE statements on all of my graphs.
Currently I have normal template variables I use in most of my dashboards (project, zone, host). Each one filters the options available in the subsequent filter…Projects have certain zones available and different host machines live in each zone. I really like being able to filter my graphs in this way however I currently use a query like the folllwing:
SELECT datapoint FROM measurement WHERE host =~ /$Host/ AND $timeFilter
This works okay but the problem is I’m constantly rewriting ALMOST the same query time and time again and I was wondering if there is a way to create stored parts of my query to reuse similar to the
I tried using a hidden constant, but it seems the variables don’t get expanded inside of that value. Essentially I would want something like the following:
STORED QUERY PART: host=~ /$Host/ FINAL QUERY: SELECT datapoint FROM measurement WHERE $storedQuery AND $timeFilter
This may seem trivial at first but imagine you now have a new requirement of your data filtering and must now go through and modify every single graph. This is where having stored query parts becomes quite useful.
Does something like this exist or is there any feature request currently?