herrx
1
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:
import "timezone"
option location = timezone.location(name: "Europe/Berlin")
from(bucket: "Einspeisung")
|> range(start: -1d, stop: now())
|> filter(fn: (r) => r["_measurement"] == "PV-Sonennstraße96-Ost" or r["_measurement"] == "PV-Sonennstraße96-Süd" or r["_measurement"] == "PV-Sonennstraße96-West" or r["_measurement"] == "PV-Sonennstraße96")
|> filter(fn: (r) => r["_field"] == "power" or r["_field"] == "P_in")
|> aggregateWindow(every: 1h, fn: mean, createEmpty: false)
|> yield(name: "mean")
I want only the Power from my solarsystem from today. right now it looks like this.
May be you could just use Grafana’s standard ranges (Today or Today so far):
And use standard range in your Flux query:
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
Does data in your InfluxDB have UTC timestamp?
grant2
3
Further to what @ebabeshko wrote, you could keep the range as
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
and then write the Query options >> Relative Time as now/d
Notice how “Last 7 days” is actually overridden:
1 Like
herrx
4
This is how my data look like
herrx
5
Thanks! “now/d” is a nice option. But how can I display the Today so far vison?
grant2
6
I do not understand your question. Today so far is specified in the Relative Time field as now/d
.
More here: Query and transform data | Grafana documentation
1 Like
herrx
7
Ahh sorry for the confusion. I want it to look like this. So Today as a default in this chart.
grant2
8
I think using 0d/d
in Time Shift should work.
BEFORE:
AFTER:
1 Like
grant2
9
@herrx Did the above work? If yes, please mark as solution so others can find it in the future.
herrx
10
Yes thanks for this advice