I use Grafana to visualize data. In order to show data availability I want to determine the number of packages/data received within a certain time, select the max and compare to the current numbers.
In Q1 I count the numbers of value in the database.
SELECT count("temperature") AS "count" FROM /^$sensor_list$/ WHERE $timeFilter GROUP BY time($__interval) fill(0)
Result looks good:
Metric | Packages Received |
---|---|
11527.count | 288 |
11525.count | 288 |
11524.count | 288 |
11556.count | 287 |
11350.count | 286 |
11526.count | 279 |
11348.count | 276 |
Now I would like to determine the maximum value from Q1 by using Q1 as Subquery in Q2.
SELECT max("count") FROM (SELECT count("temperature") AS "count" FROM /^$sensor_list$/ WHERE $timeFilter GROUP BY time($__interval) fill(0))
The result is not what I expected:
Metric | Packages Received |
---|---|
11556.max | 1 |
11528.max | 1 |
11527.max | 1 |
11526.max | 1 |
11525.max | 1 |
11524.max | 1 |
11350.max | 1 |
11348.max | 1 |
How can I get the maximum Value from the Q1 result set.