How to use browser time for query?

  • Grafana version: v8.4.7, OS: Windows (saas)

  • What are you trying to achieve?
    I have a table in a dashboard which shows data by week for last 1 year from “now”. for this, I use PostgreSQL and it’s now() function. I just take the required columns and show the data in table aggregated by week.

  • What happened?
    Now the issue is, it shows this data based on UTC time. for ex, I am behind UTC by 5 hours. I am at week 12 at the moment (9 PM Sunday night) but for UTC, it’s week 13 already (12 AM+ , Monday) and it’s Monday there. So, it shows next week’s data as well and I do not want that to happen till it’s week 13 at my place.

I know I can use timezone in SQL but it would show the dashboard by only the specified TZ. I have my teams all across the world and want them to see the data for their timezone (browser time basically)

Is there any way I can fix this. It would have been better if there was a global variable for current browser time.

I would stick with standard Grafana approach: data in the DB must be in the UTC timezone and then query result is “moved” in the Grafana frontend to browser timezone (default dashboard timezone).

Data in DB is in UTC tz itself and the need is to move in the Grafana frontend to browser tz itself. It shows the dashboard in UTC and I need it in browser tz.

So why you don’t select browser timezone?

The PostgreSql query for this particular panel(visual) does not depend on the time filter here. It has written in such a way that regardless of the time/date selected in the filter, It will show data for last 1 year from Now. Grafana is taking this ‘Now’ from UTC.

Can you redo your time series query so that in DOES depend on the time selector in Grafana?

I want data for time period ‘last 1 year from now’. If I do it time series query, that will limit my data to that selected period only. I hope you understand the use case here.

Have you played around with Query Options >> Relative Time?

Hi grant2, thanks for the comment! I never knew such thing existed!
However this didn’t seem much useful in our case since we had other calculations based on the week. Anything else that could help?