@digitaldex Oh, I just realized you’re probably using a version of Flux that doesn’t support the mo
duration unit yet. It was introduced in Flux 0.53, but I’m guessing you’re using InfluxDB 1.7. The most recent version of Flux packaged with InfluxDB 1.7 is Flux 0.50.
It’s not as graceful, but you could manually build the month timestamp as a string, then convert it to a time. The following example uses string interpolation and the strings.substring
function to extract the year and month from the timestamp returned from now()
:
import "strings"
month = time(v: "${strings.substring(v: string(v: now()), start: 0, end: 8)}01T00:00:00Z")
from(bucket: "piMeter")
|> range(start: month)
|> filter(fn: (r) => r._measurement == "downsampled_energy" and r._field == "sum_Gesamt")
|> fill(value: 0.0)
|> aggregateWindow(every: 1d, fn:sum)