Dashboard subquery help

I’m having a problem writing an influx query statement in the grafana dashboard, is it because there something wrong with my query statement or grafana-dashboard doesn’t support subqueries?

my query:
SELECT count(“clound_monit”) FROM ((SELECT “clound_monit”, “time” FROM “system1” WHERE “namespace” = ‘Production’) UNION ALL (SELECT “clound_monit”, “time” FROM “system2” WHERE “namespace” = ‘Production’)) WHERE $timeFilter GROUP BY time($__interval) fill(0)

Since measurement system1 and system2 have the same structure, I want to merge the results of both, otherwise I would need to write two query statements:
1: SELECT count(“clound_monit”) FROM “system1” WHERE “namespace” = ‘Production’ AND “EnvName” =~ /^$set$/ AND $timeFilter GROUP BY time($__interval) fill(0)
2: SELECT count(“clound_monit”) FROM “system2” WHERE “namespace” = ‘Production’ AND “EnvName” =~ /^$set$/ AND $timeFilter GROUP BY time($__interval) fill(0)
These two statements work on their own, but not when written to one union query.
If anyone can answer this I’d very appreciate it!!!

How about this?

SELECT count("clound_monit") 
  (SELECT "clound_monit", "time" FROM "system1" WHERE "namespace" = 'Production' AND $timeFilter)
  (SELECT "clound_monit", "time" FROM "system2" WHERE "namespace" = 'Production' AND $timeFilter)
GROUP BY time($__interval) fill(0)


Thank you very much for your answer, I tried this statement you provided but I still have the same problem, I will contact our operations staff later to get the version information of the relevant components.


Just to ask an odd question, but is the parameter in InfluxDB really “clound_monit” (not “cloud_monit”)?

Yes, there is indeed a spelling error here, but this measurement is really named this one. Changing the name of this measurement is no longer possible, as it is used in tooooo many places in the program :scream:

I consulted with the platform’s operations staff and the reason for this issue is that the backend storage is not exactly influxdb therefore this query statement is not supported. Thank you for your attention to this issue!

What exactly is it then?

1 Like

Maybe there are other storage engine besides influxdb in backend, but I’m not sure about since the staff didn’t tell me any more. Now this can be interpreted as a backend limitation on the query statement. I’m using “add field from calculation” in transform to do this now.

Hard to help you further nor interpret what the backend is when you do not know the type of data source.

Doctor I have a major pain somewhere in my body, not sure where, but could you please cure me? :wink: