Stat panel is not based on time range

Hi,

I’ve retrieved a docker image that includes an existing dashboard that display temperatures graphs based on a time range.

On the side, there’s some stat panels that display min / max / avg values of the temperature but I realized that those are requested over the entire dataset and are not restricted to the selected time range that is applied to the graph.

Being totaly new to grafana, i tried to look at the settings and various documentation pages.
I was trying to modify the request itself but by comparing it with the graph settings (that are restricted to the time range), i cannot see either how they’re restricted (the SQL of the graph looks like : “Select temp from temperatures”) and I cannot find the option that link it to the time range. So I guess i’m not looking at the right place…

  • What Grafana version and what operating system are you using?
    v9.1.6
  • What are you trying to achieve?
    Stat panel that’s restricted to the dashboard selected time range
  • How are you trying to achieve it?
    panel settings
  • What happened?
    panel not restricted to time range (min/max/mean values retrieves over the entire data range)
  • What did you expect to happen?
    panels retrieving mean/max/min values over selected time range only

There’s no data because i’m not at home, so the DB is not available, but neverthelsse here are the current settings

Welcome

What database type is it and are you familiar and comfortable with writing sql queries for that db product?

Thanks :wink:

It’s an influxDB v1.8.
Yes, I’m very familiar with with SQL queries (oracle/MSSQL).

I don’t know if was clear in my first message.
The dashboard contains 2 different panel, a timed graph and a stat panel.
The time graph works as expected regarding time range, but the panel is not.
At first I intended to replicated the graph query filters in the stat panel query.
But in the graph settings, there’s no where clause on the timerange (at least not in the query window, or in the side settings).
So this got me thinking there’s probably something else to be done than just adding an equivalent of “where timestamp between time_range_start and time_range_end”

As this is from a docker container, the original dashboard json definition is accessible on

Here is what is defined for the graph panel

Graph panel that is working

“groupBy”: [
{
“params”: [
“$__interval”
],
“type”: “time”
},
{
“params”: [
“null”
],
“type”: “fill”
}
],
“orderByTime”: “ASC”,
“policy”: “default”,
“query”: “SELECT temp FROM "Temperatures" WHERE "name" = ‘$zone’”,
“queryType”: “randomWalk”,
“rawQuery”: true,
“refId”: “A”,
“resultFormat”: “time_series”,
“select”: [
[
{
“params”: [
“value”
],
“type”: “field”
},
{
“params”: ,
“type”: “mean”
}
]
],
“tags”:

And here is one of the stat panel :
I cannot figure out what’s different and why one is working but not the other

Stat panel that is not working

“groupBy”: [
{
“params”: [
“$__interval”
],
“type”: “time”
},
{
“params”: [
“null”
],
“type”: “fill”
}
],
“orderByTime”: “ASC”,
“policy”: “default”,
“query”: “SELECT temp FROM "Temperatures" WHERE "name" = ‘$zone’”,
“queryType”: “randomWalk”,
“rawQuery”: true,
“refId”: “A”,
“resultFormat”: “time_series”,
“select”: [
[
{
“params”: [
“value”
],
“type”: “field”
},
{
“params”: ,
“type”: “mean”
}
]
],
“tags”: