Reputation: 171
This is my query:
from(bucket: "power_monitor")
|> range(start: today())
|> aggregateWindow(every: 1h, fn: mean, createEmpty: false)
|> keep(columns: ["_measurement", "_value", "_time"])
|> increase()
|> last()
It tracks the amount of energy used since the start of the day, except I think the timezone is wrong... it was working perfectly until ~8pm when all values were reset to zero.
Can I fix this in the query by adding a time offset? or set my timezone? I think I'd like the values to reset around 2am.
I got this from influx docs and added it to the query, but it doesn't seem to help (still all zeros):
import "timezone"
timezone.fixed(offset: -4h)
Upvotes: 0
Views: 2266
Reputation: 465
You need to set location
option, ie.
import "timezone"
option location = timezone.fixed(offset: -4h)
from(bucket: "power_monitor")
...
Or use location
parameter of aggregateWindow
function, ie.
from(bucket: "power_monitor")
...
|> aggregateWindow(every: 1h, fn: mean, createEmpty: false, location: timezone.fixed(offset: -4h))
Upvotes: 2
Reputation: 171
I think I found a workaround, but accepted answer will be one which uses timezones and not experimental function.
workaround:
import "experimental"
starttime = () => experimental.addDuration(d: -6h, to: today())
from(bucket: "power_monitor")
|> range(start: starttime())
|> aggregateWindow(every: 1h, fn: mean, createEmpty: false)
|> keep(columns: ["_measurement", "_value", "_time"])
|> increase()
|> last()
Upvotes: -1