Hello everyone,
I have requirement where I need to show data from 3 shift that employees work in:
- Shift 1 (00:00 → 08:00)
- Shift 2 (08:00 → 16:00)
- Shift 3 (16:00 → 00:00)
I have worked out the query for first shift as below:
import "date"
today = date.truncate(t: now(), unit: 1d)
from(bucket: "MyBucket")
|> range(start: today)
|> filter(fn: (r) => r["_measurement"] == "MyMeasurement")
|> filter(fn: (r) => r["_field"] == "myField")
|> hourSelection(start: 0, stop: 7)
|> timeShift(duration: -5h30m, columns: ["_start", "_stop", "_time"])
|> aggregateWindow(every: 2s, fn: mean, createEmpty: false)
|> yield(name: "mean")
Note: I have added timeSift as I am in UTC+5.30 timezone. So moving backward by 5.30 to start getting data from start of the day.
Strangely I have set option to Local in Explorer but without timeShift option it gives me data from 5.30 AM
However if I try to set hourSelection as : hourSelection(start: 7, stop: 15)
It only gives me data upto 10.30 AM. I am not sure why hourSelection is not working in this scenario:
Shift B query (not working)
import "date"
today = date.truncate(t: now(), unit: 1d)
from(bucket: "MyBucket")
|> range(start: today)
|> filter(fn: (r) => r["_measurement"] == "MyMeasurement")
|> filter(fn: (r) => r["_field"] == "myField")
|> hourSelection(start: 7, stop: 15)
|> timeShift(duration: -5h30m, columns: ["_start", "_stop", "_time"])
|> aggregateWindow(every: 2s, fn: mean, createEmpty: false)
|> yield(name: "mean")
Can anyone help me with this please ?