Hello Grafana Community,
I’m currently facing an issue with the time range on my Grafana dashboard. I’m using InfluxDB as my data source and Flux as my query language.
Here’s the Flux query I’m using:
from(bucket: “BF23Arm1”)
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r[“_measurement”] == “TOTAL _ DEFECT_VISUAL”)
|> filter(fn: (r) => r[“_field”] == “value”)
|> aggregateWindow(every: 1h, fn: last, createEmpty: false)
|> yield(name: “last”)
I want to plot the graph in 1 hr window e.g 6:00 ~ 7:00, 7:00 ~ 8:00 and so on
Check if adding timeSrc: "_start"
parameter to your aggregateWindow
helps.
What time range is selected in Grafana?
@ebabeshko
Thanks for the help
As suggested use |> aggregateWindow(every: 1h, fn: mean, timeSrc: “_start”) but same condition.
Time range in grafana is 1 H
I mean what do you have selected in Grafana’s time picker:
This looks more like a workaround rather than a solution, but try adding
|> timeShift(duration:30m)
or
|> timeShift(duration:-30m)
to your query:
@ebabeshko
i have added the time shift function in query, now the quert is like this:
from(bucket: “your_bucket”)
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r[“_measurement”] == “TOTAL _ DEFECT_VISUAL”)
|> filter(fn: (r) => r[“_field”] == “value”)
|> aggregateWindow(every: 1h, fn: last, createEmpty: false)
|> timeShift(duration:30m)
|> yield(name: “last”)
As a result the time is shifted in graph, please see the attached image but last bar time is more than current time.
Experiment with timeSrc: "_start"
and |> timeShift(duration:30m)
@ebabeshko
I tried as per your suggestion , it works with time stamp but data is shifted