InfluxDB: Issue with Time Range start from middnight

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?

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

This is how my data look like

Thanks! “now/d” is a nice option. But how can I display the Today so far vison?

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

Ahh sorry for the confusion. I want it to look like this. So Today as a default in this chart.

I think using 0d/d in Time Shift should work.



1 Like

@herrx Did the above work? If yes, please mark as solution so others can find it in the future.

Yes thanks for this advice :slight_smile: