influxdb
influxdb copied to clipboard
Inability to manipulate range offsets in dashboards
InfluxDB 2.0.2
Original task is simple I want to have on a plot some data for closen interval and data for previous interval with fixed shift/offset on the same plot (i.e shifted data will be shifted to current interval) Shift is solved but timeShift() , but selection is not solvable.
So, let assume typical query:
from(bucket: "bucket")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r["_measurement"] == "hmeasurement")
|> filter(fn: (r) => r["_field"] == "field")
|> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)
|> yield(name: "mean")
Problem is to have another query in a equivalent form of
from(bucket: "bucket")
|> range(start: v.timeRangeStart-24h, stop: v.timeRangeStop-24h)
|> timeShift(duration: 24h)
|> filter(fn: (r) => r["_measurement"] == "hmeasurement")
|> filter(fn: (r) => r["_field"] == "field")
|> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)
|> yield(name: "mean")
And in this query, particularly, line
|> range(start: v.timeRangeStart-24h, stop: v.timeRangeStop-24h)
is not solvable.
you can use custom variable for start:
here, but using anything but v.timeRangeStop
for the stop:
(or custom variable which is defined like t=v.timeRangeStop
) , leads to the error record is missing label windowPeriod
. (I tried to alter t
with add/subDuration)
So, unless there is something obvious I am missing, there is a clear bug or missing feature. And I don't think it is such exotic use case. (let say you want to compare this week performance to last week performance).
Maybe, I am wrong, but I presume this should work:
t0=experimental.subDuration(from: v.timeRangeStart,d: 24h)
t1=experimental.subDuration(from: v.timeRangeStop,d: 24h)
from(bucket: "bucket")
|> range(start: t1, stop: t2)
|> timeShift(duration: 24h)
|> filter(fn: (r) => r["_measurement"] == "hmeasurement")
|> filter(fn: (r) => r["_field"] == "field")
|> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)
|> yield(name: "mean")
data-wise, this query is all right. And I can successfully query in CLI:
import "experimental"
t1=experimental.subDuration(from: now(), d: 24h)
t0=experimental.subDuration(from: t1,d: 24h)
from(bucket: "bucket")
|> range(start: t1, stop: t2)
|> timeShift(duration: 24h)
|> filter(fn: (r) => r["_measurement"] == "hmeasurement")
|> filter(fn: (r) => r["_field"] == "field")
|> aggregateWindow(every: 15m, fn: mean, createEmpty: false)
|> yield(name: "mean")
But using the very same query in query editor in InfluxDB dashboard UI results in record is missing label windowPeriod
error.
Likewise, I also get type error @14:29-14:30: record is missing label windowPeriod
with
import "experimental"
time = experimental.addDuration(
d: 3600s,
to: 2021-04-19T11:00:00Z
)
from(bucket: "Website Monitoring Bucket")
|> range(start: v.timeRangeStart, stop: time)
In C2. I expect that to work. Thank you :)
In InfluxDB 2.0.4 (Docker image) I get the same error : type error @5:29-5:30: record is missing label windowPeriod
Following Flux code was used against a Mariadb 10.2.9 database
import "sql"
password = "the-super-secret-password"
sql.from(
driverName: "mysql",
dataSourceName: "username:${password}@tcp(mysql:3306)/mysql",
query: "select * from slow_log"
)
I have same problem trying to solve missing first two points after doing derivative.
start2 = duration(v: int(v: v.timeRangeStart) - 3*int(v:5m))
from(bucket: "telegraf/two_years")
|> range(start: start2, stop: v.timeRangeStop)
...
|> aggregate.rate(every: 5m, groupColumns: ["_field", ...])
...
When I change last line to:
|> aggregate.rate(every: v.windowPeriod, groupColumns: ["_field", ...])
I get a error:
error @24:30-24:31: record is missing label windowPeriod
When I change this to:
from(bucket: "telegraf/two_years")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
...
|> aggregate.rate(every: v.windowPeriod, groupColumns: ["_field", ...])
It works, but not quite, I'm missing 1-2 beginning points on graph. It looks good when I'm zoomed out, but becomes more useless when zoomed in to 15m (samples every 5m).
Same issue for me:
import "experimental"
from(bucket: v.bucket)
|> range(start: v.timeRangeStart, stop: experimental.subDuration(d: 1m, from: v.timeRangeStop))
...
I get this error:
type error @18:29-18:30: record is missing label windowPeriod
same problem here... not sure why 2.5 years later there is no comment on this
同样的问题......不知道为什么2.5年后对此没有评论
me,too sad
I believe I am also getting the same issue. Pretty simple use-case and strange that it happens.
Same issue here
also here, quite important feature