I have a influxDB data set containing a large number of time series data from a bunch of virtual machines.
I’m trying to set up a variable to return the names of the top 10 machines with the highest cpu usage above a threshold.
The following query works in the query editor (I can get the results I want in a panel):
SELECT “name” FROM (SELECT TOP(usage, 10), “name” FROM (SELECT SUM(“cpu”) AS usage FROM “location” WHERE (“type”=~/^$microservice$/) AND $timeFilter AND “cpu” >= $cpuLimit GROUP BY “name”))
But when I try and define a new variable with this query, it errors out. For reference, $microservice is the name of the program selected, and $cpuLimit is another variable containing the threshold.
If I do:
SELECT “name” FROM (SELECT TOP(usage, 10), “name” FROM (SELECT SUM(“cpu”) AS usage FROM “location” WHERE (“type”=~/^$microservice$/) AND $timeFilter AND “cpu” >= 0.5 GROUP BY “name”))
Then the variable works just fine. It’s when I put in the $cpuLimit that I get the following errors: Validation and Templating Errors
Which says that there’s an unexpected character at position 216, but there’s not even 216 characters in my query so I am a bit lost. Why does it work in a panel but not in a variable? Any thoughts would be much appreciated!