Subquery inside continious query

Hello,

I found this topic which shows how to get an overall availability of hosts, which was most helpful. If i use the query in Grafana to create a single stat panel it works. If i try to use the query in a graph to show a history over the month i get no data points.

My plan is to run a continious query that will give me the value i want, which i can use to populate the graph. My problem is this (not grafana related!). When i try to add the query to Influx i get one of 2 error message.

The query is as follows:

create continuous query "availability" on "virtualbox" BEGIN select sum("isUp") / count("isUp") INTO "system" from (select non_negative_derivative(mean("uptime")) / non_negative_derivative(mean("uptime")) as isUp INTO "system" from "system" where "host" = 'server1' group by time(5m)) END

Which results in:

ERR: error parsing query: found ), expected GROUP BY time(...) at line 1, char 284

If i drop the extra ) from the end of the query, i get a slightly different error.
ERR: error parsing query: found END, expected ) at line 1, char 285

From what i can tell using visual studio, the brackets balance and i cannot figure out why I’m getting this error. Surely it is possible to use a subquery within a continous query? Is there slightly different syntax when using a sub query or have a just missed something/am ibeing thick?

Any help much appreciated! thanks, Philb