I’m using Grafana with InfluxDB 1.1.
Here is the data that I have selected in my current view (also comma separated at the bottom in case you want to copy it):
I get strange results from some InfluxDB queries (with “tag_id” as a templating variable).
SELECT median("field1") FROM "measurement1" WHERE "tag_id" =~ /^$id$/ AND $timeFilter GROUP BY time($interval) fill(null)
A singlestat panel with this query shows 45.6 which is obviously not the median of field1. mean("field1")
also gives the same wrong result (45.6).
However, the same query with sum("field1")
yields the correct result (45.6). count("field1")
is also correct (8).
Then I’d like to divide the sum of field1 by the sum of field2:
SELECT sum("field1")/sum("field2") FROM "measurement1" WHERE "tag_id" =~ /^$id$/ AND $timeFilter GROUP BY time($interval) fill(null)
This shows 6.53 in the singlestat panel. While the correct result is 0.8144 (= 45.6/55.9911).
Why is the result of median()
, mean()
, and sum()/sum()
wrong here?
Table (comma separated):
timestamp,field1,field2
20.02.16 13:03,11.1,7.053333
12.04.16 07:04 4,7.178889
16.04.16 13:47 ,8.7,6.644167
21.04.16 15:58 ,7.75,7.283333
27.04.16 08:41 ,3.45,6.976667
02.05.16 07:55,1.9,7
11.05.16 09:52 ,3.9,7.062778
17.05.16 14:05 ,4.8,6.791944