Convert InfluxQL to Flux query

Notice: Page may contain affiliate links for which we may earn a small commission through services like Amazon Affiliates or Skimlinks.

Rand__

Well-Known Member
Mar 6, 2014
6,626
1,767
113
Anyone having experience with Flux willing/able to help out?

Looking to convert an Influx query to a Flux query for a Grafana power consumption panel...
Influx query works fine for everything at day or hour level but wont do month or year ...

Code:
SELECT SUM("power"::float) / (60.0 )
 FROM (
    SELECT mean("value") AS power FROM "mydatapoint" WHERE $timeFilter GROUP BY  time(1m)  tz('Europe/Berlin')
  )
GROUP BY time(30d)  tz('Europe/Berlin')
This query takes all datapoints in the timerange and averages them over 1 minute. It then sums them up (divided by 60 to get hour values) grouped whatever reporting period is desired.
InfluxQL can't do 1mo/1y grouping here unfortunately...


Flux can do it but I have not the slightest idea how to use it;)
 

Rand__

Well-Known Member
Mar 6, 2014
6,626
1,767
113
I made some progress, but no final solution yet. Asked for help over in the flux forum just in case somebody is interested

Edit - got a 95% solution working there, in case you're interested. Only timezone not working as expected.
 
Last edited: