Hi,
I’m collecting the energy price on an hourly basis into InfluxDB. I’m trying to setup a query that would give me an updated average price of energy during current month.
Flux Query:
import “strings”
month = time(v: “${strings.substring(v: string(v: now()), start: 0, end: 8)}01T00:00:00Z”)
from(bucket: “bucket”)
|> range(start: month)
|> filter(fn: (r) => r[“_measurement”] == “energyprice”)
|> filter(fn: (r) => r[“_field”] == “value”)
|> aggregateWindow(every: 31d, fn:mean)
Does this look correct? I am not sure how I should setup the aggregateWindow.
Idea is that the query would give me a continuous update on the average price during a calendar month.
So f.ex on the 15th of December it should show me the average of all samples between 1-15th and so on.