influxdata / influxdata/influxdb

Inability to manipulate range offsets in dashboards

Open
#20,323 8 comments 8 reactions 0 assignees View on GitHub
area/2.x area/flux
Dominant language
Rust
Stars
31.7k
Forks
3.7k
Avg merge
13h 37m
Merged PRs (30d)
8

Description

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.

Contributor guide

Open the contributing guide

Research direction

Reproduce the supplied query in the dashboard query editor and compare it with the CLI result. Focus on the dashboard UI's handling of shifted range expressions and the `windowPeriod` error; done means the equivalent previous-interval query runs in the dashboard without that error.

Written by the indexing model from the issue text.

Assessment

Domain
databases, frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.