Relative time functionality on panel broken

I want a time series panel to use a relative time configured in the panel independent from the time picker in the dashboard. I configured the panel with a relative time “now-1y” in the query options.

This works for a moment, but every time the dashboard is autoupdated the time range from the dashboard is applied again. No error message shown …

Of course I expect the configured panel specific range to always override the range from the dashboard. How do I achieve this?

My environment: Latest grafana-oss docker image on debian on a raspi 4. I’m using Flux btw. and the flux query returns the expected data.

(Edit: The behavior was the same with version 10.2.3, 10.2.8, 10.3.0. I checked whether this was possibly a bug already fixed …)

It works (overrides) for relative dashboard time ranges (last day, hour, …) only. It doesn’t override panel time range if dashboard has absolute time range (2024-07-20 00:03:00 - 2024-07-20 00:13:00).
That’s by design:
you have relative dashboard range initially → you spot some problems, so you zoom in into problem period = you have absolute dashboard time range → all panels will focus on that problem period.

I was aware of this. (It was mentioned somewhere in this forum IIRC.) The behavior you describe would be fine for me.

But this is not the problem. I use “Last 6 hours” on dashboard level. However the dashboard keeps switching between these states on updates:


Note the lower time series panel has different scales in both images. The time range in the dashboard is “last 6 hours”, auto refresh is 10 seconds.

Edit: Also the panel shows “Last 1 year” in both cases, even when only the last 6 hours are actually displayed. This at least I would consider a defect. If there were good reason to display another time range the panel must of course not indicate a time range that is simply not what’s shown …

Sure. Check github issues, maybe it was reported already or report it eventually.

Done. Reference / backlink:

1 Like

It works on my computer ™ (so I will sell you my computer :-D): Grafana
Problem can be browser/browser plugin/non grafana labs plugin/… - any problems in browser console?
Are you able to replicate your isue on vanilla Grafana installation (official Docker x86 image) and Chrome/Firefox browser?

The issue is exactly the same with Chrome and Firefox (both at least recent if not latest versions, both totally clean / no plugins). I checked the console in Chrome: Nothing.

(I have created a video, I just cannot upload it here. Any recommendations where I would make this available?)

My Grafana docker image is the official one. AFAIK this is a multi platform image for ARM and x86. But I have no way to actually run this on an x86 machine due to lack of suitable hardware.

I do have a plugin in Grafana (it’s a sun and moon thing), however this is not used on the dashboard in question.

Regarding your computer: It also runs fine on the demo dashboard provided by the Grafana team. If it wouldn’t this would have been so very obvious that someone else would have identified this long before I did. Isn’t the act of finding subtle differences which make bugs appear the very aspect that makes hunting bugs so interesting? :slight_smile:

Are you able to replicate it with another type of datasource, e.g. testData ?

I can replicate this with the default random data time series panel.

However not on a new dashboard. I.e. there must be a dependency from something else in the dashboard.

As a next step I will now duplicate the dashboard and start deleting other panels.

1 Like

I was mistaken. I DID reproduce this on a completely fresh dashboard with only the random walk time series panel.

To add to the mystery: The random walk data is updated every 10 seconds which is easy to observe because the data completely changes every time. The switch to the wrong time range however does not occur on every refresh, rather at random occasions.

I’m totally lost now. At this moment I haven’t got the slightest idea left of what to analyze.

Please publish that dashboard.

Here it is.

It does not behave consistently. I have a video showing the panel immediately switching to a wrong time scale, then switching back and staying there. It does not happen every time I open this dashboard.

{
  "__inputs": [],
  "__elements": {},
  "__requires": [
    {
      "type": "grafana",
      "id": "grafana",
      "name": "Grafana",
      "version": "11.1.2"
    },
    {
      "type": "panel",
      "id": "timeseries",
      "name": "Time series",
      "version": ""
    }
  ],
  "annotations": {
    "list": [
      {
        "builtIn": 1,
        "datasource": {
          "type": "grafana",
          "uid": "-- Grafana --"
        },
        "enable": true,
        "hide": true,
        "iconColor": "rgba(0, 211, 255, 1)",
        "name": "Annotations & Alerts",
        "type": "dashboard"
      }
    ]
  },
  "editable": true,
  "fiscalYearStartMonth": 0,
  "graphTooltip": 0,
  "id": null,
  "links": [],
  "panels": [
    {
      "datasource": {
        "type": "grafana",
        "uid": "grafana"
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "axisBorderShow": false,
            "axisCenteredZero": false,
            "axisColorMode": "text",
            "axisLabel": "",
            "axisPlacement": "auto",
            "barAlignment": 0,
            "drawStyle": "line",
            "fillOpacity": 0,
            "gradientMode": "none",
            "hideFrom": {
              "legend": false,
              "tooltip": false,
              "viz": false
            },
            "insertNulls": false,
            "lineInterpolation": "linear",
            "lineWidth": 1,
            "pointSize": 5,
            "scaleDistribution": {
              "type": "linear"
            },
            "showPoints": "auto",
            "spanNulls": false,
            "stacking": {
              "group": "A",
              "mode": "none"
            },
            "thresholdsStyle": {
              "mode": "off"
            }
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "red",
                "value": 80
              }
            ]
          }
        },
        "overrides": []
      },
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 0,
        "y": 0
      },
      "id": 1,
      "options": {
        "legend": {
          "calcs": [],
          "displayMode": "list",
          "placement": "bottom",
          "showLegend": true
        },
        "tooltip": {
          "mode": "single",
          "sort": "none"
        }
      },
      "targets": [
        {
          "datasource": {
            "type": "datasource",
            "uid": "grafana"
          },
          "queryType": "randomWalk",
          "refId": "A"
        }
      ],
      "timeFrom": "now-1y",
      "title": "Panel Title",
      "type": "timeseries"
    }
  ],
  "refresh": "10s",
  "schemaVersion": 39,
  "tags": [],
  "templating": {
    "list": []
  },
  "time": {
    "from": "now-6h",
    "to": "now"
  },
  "timepicker": {},
  "timezone": "browser",
  "title": "bbbb3",
  "uid": "edt0nx2oecav4c",
  "version": 2,
  "weekStart": ""
}

It works on my arm server: http://132.145.16.26:3000/d/edt0nx2oecav4c/bbbb3?orgId=1&refresh=5s (yeah, it’s public with full admin Grafana access :-D)

docker run -d \
  --name grafana \
  -e GF_AUTH_ANONYMOUS_ENABLED=true \
  -e GF_AUTH_ANONYMOUS_ORG_ROLE=Admin \
  -p 3000:3000 \
  grafana/grafana:11.0.1

My guess: you have something in your network (WAF, proxy, antivirus, caching, packet inspection, …) which may mess response content.

1 Like

Thank you very much for investing that much time for investigation!

On your server the dashboard looks fine to me as well. That rules out processor architecture as a cause.

I’m pretty sure a network issue is not the cause. I do not employ any of a WAF, proxy / reverse proxy, antivirus within my local network between the server and my MacBook. No packet inspection / IDS/IPS is in place in my network. Caching? If so then at the bowser level (no caching proxy in my network either).

Very mysterious, really. No leads left so I will stop further investigation. Perhaps this topic will resurface somewhere else.

I would try to switch to more powerful HW. You can run test on MacBook directly.

Just for the records an animated gif showing the behavior with the dashboard above.

Grafana 2.mp4

I have the same problem.
Have tryd alot of things without luck (query edit, json edit etc.)
Im not sure if it fully fixed the problem or not, but when I changed the global time range on dashboard from “last 8 hours” to “yesterday”, it somehow works on my managed grafana instance…
Can you check, and see if the same happends to you?

I have difficulties to reliably reproduce this behavior now. It actually happens rather seldomly. That means if it does not occur when configuring the dashboard to “Yesterday” this is not an indication that there is any connection.

However as @jangaraj mentioned right from the start there is a difference in behavior between relative and absolute dashboard ranges. This may play a role here.

I believe I’m seeing a similar problem, running Grafana 11.3.0 on a Raspberry Pi 5. I saw the same thing using the Hourly Heatmap plugin, which led me to try and recreate the same visualization with the regular Heatmap. It works well, except when I try to use the Relative Time setting.
I’d like it to always display the last year. However, when I set Relative Time to anything at all, the X-axis scales to the last six hours, and no data is displayed.
Interestingly, though, when Relative Time is unset, just clicking on and off the Relative Time or Time Shift text boxes causes the same problem to toggle on and off.

Animation

Hello,

I have the exact same issue.
If I put anything into the Relative Time Setting, everything seems to break.
Not even setting the time picker time to 5 minutes will revert it back to 5 min. It will always stick to 6 hours.
Very weird.
Is there a github issue already covering this?