{
"measurement": "temperature",
"tags": {
"location": "office"
},
"time": "2023-05-05T12:00:00Z",
"fields": {
"value": 22.5
}
}
-- querying
SELECT MEAN("value")
FROM "temperature"
WHERE time > now() - 10m
-- downsampling
SELECT MEAN("value")
INTO "temperature_downsampled"
FROM "temperature" GROUP BY time(1h)
-- querying (aggregate)
from(bucket: "get-started")
|> range(start: 2022-01-01T08:00:00Z, stop: 2022-01-01T20:00:01Z)
|> filter(fn: (r) => r._measurement == "home")
|> filter(fn: (r) => r._field == "co" or r._field == "hum" or r._field == "temp")
|> mean()
-- downsampling
from(bucket: "get-started")
|> range(start: 2022-01-01T14:00:00Z, stop: 2022-01-01T20:00:01Z)
|> filter(fn: (r) => r._measurement == "home")
|> filter(fn: (r) => r._field == "temp")
|> aggregateWindow(every: 2h, fn: mean)
-- tasks
option task = {
name: "Example task"
every: 1d,
}
from(bucket: "get-started-downsampled")
|> range(start: -task.every)
|> filter(fn: (r) => r._measurement == "home")
|> aggregateWindow(every: 2h, fn: mean)