Setting different panels to different time ranges in a single dashboard

Is there an equivalent way of doing this from the UI?
Maybe through the override section?
I could not find any information on this.

1 Like

You can edit the JSON of each panel by clicking on a panel title, going down
to “More…” and then clicking on “Panel JSON”.

Alternatively you can edit all the panels in a dashboard by clicking on the
gearwheel for “Dashboard settings” and then “JSON Model”.

Antony.

2 Likes

Is there a schema for that json somewhere? Because I am not quite sure where to place the timefrom and hidetimeoverride. This is what my json looks like:

{
  "datasource": "grafanacloud-foo-prom",
  "fieldConfig": {
    "defaults": {
      "thresholds": {
        "mode": "absolute",
        "steps": [
          {
            "color": "green",
            "value": null
          }
        ]
      },
      "mappings": [],
      "color": {
        "mode": "thresholds"
      },
      "min": 0,
      "unit": "decbytes"
    },
    "overrides": []
  },
  "gridPos": {
    "h": 4,
    "w": 5,
    "x": 5,
    "y": 6
  },
  "id": 13,
  "options": {
    "reduceOptions": {
      "values": false,
      "calcs": [
        "lastNotNull"
      ],
      "fields": ""
    },
    "orientation": "auto",
    "text": {},
    "textMode": "auto",
    "colorMode": "value",
    "graphMode": "area",
    "justifyMode": "auto"
  },
  "pluginVersion": "7.5.6",
  "targets": [
    {
      "exemplar": true,
      "expr": "mongobackup_dump_size",
      "interval": "",
      "legendFormat": "",
      "queryType": "randomWalk",
      "refId": "A"
    }
  ],
  "title": "Backup Size",
  "type": "stat"
}

Is there a schema for that json somewhere? Because I am not quite sure
where to place the timefrom and hidetimeoverride.

They’re both top-level JSON values, and the order doesn’t matter (Grafana will
put them alphabetically if you do an export).

So, do something like:

“title”: “Backup Size”,
“hideTimeOverride”: true,
“timeFrom”: “7d”,
“type”: “stat”

Antony.

1 Like

FWIW, I feel like this is also possible from the time range override in the panel query options in the UI (Queries | Grafana Labs). Though maybe that doesn’t provide the level of flexibility desired here…

2 Likes

Hi

I have this exact same issue, I want to track the light level for my plants over the past 3 hours but the temperature and humidity over the past 7 days.

No matter what I try, I can not get these JSON properties to work. Every time I paste them into JSON Model and press Save, Grafana just overwrites “timeFrom” to null and removes “hideTimeOverride” completely.

edit: here is my model: https://pastebin.com/QeREyqjj
edit2: by the way, there used to be a way only three years ago as seen in this post: Multiple Time range? - #8 by torkel but it looks very different now and the “Time Range” tab is nowhere to be found. :frowning:

@longoon12000 did you take a look at the link in my post? I’m not sure why people are resorting to manual JSON edits for this. The option to override the time range for a particular panel is (still…years later) right there under “Query options”, next to the datasource selector in the panel edit screen. Just select whatever custom time range you need for that individual panel (e.g. “7d”) and you should be sorted.

2 Likes

@svetb I have looked into these options and it seems that “Relative Time” is indeed what I need. I had trouble finding this field because it didn’t have this (i) popover that explained what it does and also does not have “range” in its name.
To be honest I didn’t even understand what Relative Time could possibly mean so it was prone to be ignored as an option by me. It was only in the documentation where this was explained and I understood it.
Thanks!

3 Likes

@longoon12000 I think your point about how (non-)intuitive it is to find (or understand) that option is certainly spot on! I do feel like it was called something more obvious previously, and it also potentially had an info pop-up that’s no longer there. Probably a valuable enhancement request to get this sorted. Based on the above thread, you’re clearly not the only one who’s had trouble finding it in the UI…

2 Likes

Hi,

I tried to modify the json - but that does not work for me. I do not find the parameter “hidetimeoverride” and when I try to add the parameter, there comes an error message.

I only found this:

“timeFrom”: “”,
“title”: “$filter_description”,
“type”: “timeseries”,
“timeShift”: null,
“datasource”: null

So how can the JSON be modified exactly for changing the time range. Is it possible to use variables as input parameters in the JSON or defined dates for “timefrom” (like “2021-03-11 12:09:41.340” → correct format?)?

Thank you!
Greetings
Patrick

Hello there. I’m struggling with this issue, but I cannot make it work.
The parameter timeFrom seems to fix the panel to the last 24 hours (or 24 hours so far). What I need is to show in one panel the last month, and in another today.

My time range filter is from now/M to now/d.

If I delete the timeFrom parameter, the panel shows the rest of the day, but the from time is one month ago (taken from the general time range), but when in the “today” panel I set the timeFrom 1d, it shows the last 24 hours until this moment, not the whole day from 00:00:00

Does anyone know if that is possible?

Hi,

You can try to use compare queries plugin that allow you to add new database to make this comparaison with exsiting database.

I also could get setting JSON fields to change time range per panel
But Query options | Grafana documentation worked for me. Hope this is helpful.

And still… years later… it has an absolute useless label called “relative time”. Why is it not called “time range” or even better “override time range”?
And you still wonder why people don’t find it?

Is there also a setting for timeTo? The “relative time” from the gui seems to set the “timeFrom” according to the manual JSON changes mentioned here.

I do not only need panels from now back to various points in the past, i want to use e.g. “today” (NOT so far) and “yesterday”. But that requires a timeTo that is not “now”.

2 Likes

Click at Query options > Relative time 15m (last 15 minutes) or 7d (last 7 days)

5 Likes

OMG you saved me. That works.

1 Like

Hi guys , in relation to the topic:

I will have a dashboard table with columns : address, price , procent

i want to be able to filter the table by changing the time period From → TO , my API will return the array of data based on that period . Is there a way to make the table url dynamic based on the time period i choose ?

Hello,
I also posted a question on the subject yesterday.
I wanted to use Relative Time to display data from a specific day in the past. This should be done alongside other panels that use a different time range.
But it doesn’t work.

Big mistake on my part. I was trying to change the X-Axis (i.e. time range.) I kept changing it in the (Panel)–>Edit–>(Time Range) and choosing “Last 30 Days.” I would save it, close the edit page, and hit the link I had for the dashboard, to check, and it kept reverting to the 6-hour setting I wanted to get rid of.

I eventually realized that the 6h time range was embedded in the URL of the pane.

Don’t be like me. :slight_smile:. Make sure your testing/operations URL doesn’t force the (unwanted) time period before checking your dashboard.

http://nnn.nnn.nnn.nnn:3000/d/abcdefg/water-softener?orgId=1&from=now-6h&to=now

…was forcing it to 6 hours.

1 Like

Thanks! It’s work for me, by the way the name “Relative Time” is so weird…