Set individual graph to fixed time frame

Hi Everyone,

i built a small grafana panel for visualising my PV system.
To show the power distribution over time for today i selected a time series graph, but can’t figure out to set the graph to only show the area with actual data or a set time, e.g. from 5 in the morning to 9 in the evening. The only way i come close is set some relative time from now, or the entire day (24h) in the query options which is a waste of space because the sun is not shining at night :grinning_face:

Can someone help me out how to configure my graph to only show a fixed time frame of the day? (My global Dashboard is set to show the last hour)

Grafana Version: v10.4.1
InfluxDB Version: v2.7.11

Thank you very much in advance :slight_smile:

Welcome @stratocaster . You can call me Les Paul :guitar:

Are you using Flux? If yes, the hourSelection function looks like it will work well for you.

Thanks for your answer :slight_smile:

I am using InfluxDB.

How can i use this hour selection in Grafana?
I am not an expert and only used the basic grafana editor / query builder so far :sweat_smile:

InfluxDB has 3 possible query languages. Which one are you using?

The hourSelection function is available in Flux only.

i am using the “regular” grafana InfluxDB editor mode which looks like this:

SELECT mean("value")  * -1 
  FROM "smartmeter.1.value" 
 WHERE $timeFilter 
 GROUP BY time($__interval) fill(linear)

You are using InfluxQL.

Flux has hundreds of functions that are not available in InfluxQL (plus you can define / build your own). The hourSelection function would be perfect for your application, but unfortunately it’s only available in Flux.

Is there a way to achieve this with the “query options” function or otherwise in grafana itself?

Not that I am aware of.

You can achieve this by setting a custom time range for that specific panel. In the panel settings, go to Overrides and use the Time range option to define a fixed window, like 05:00 - 21:00 shades conroe tx. This way, your graph will only display data from that period without affecting the global dashboard settings.

Thanks for your answer, but unfortunately i can’t find an override for time range, only for time zone.