No timezone global variable?

Hi,

Is there no timezone global variable (Grafana 8.x) ? (it seems very surprising)

If not, any chance it is on the roadmap?

Thanks so much
Best
Benoit

For what purpose and how would you expect to use such a variable?

Almost everything Grafana does expects data to be in UTC, and local timezones
cause all sorts of problems when there are two instances of 2:38am in one day,
for example.

Where / how do you think you need to use a local timezone indicator?

Antony.

Thanks, I should have specified that.

I work mostly with the PostgreSQL data source & raw SQL queries but I think it could apply to other data sources as well.

I have two use cases I would need that:

  • Creating some text columns in the query to render/prepare text on the server-side involving timestamps → I need the browser timezone to know how to format my timestamps (which are in UTC in the database, as it should be)

  • I have queries in which I only care about the date component in the time selector (i.e. i don t care about selected time hh:mm) and just want to filter based on date. But if i filter on timecolumn::date (or date_trunc(‘day’, timecolumn) ) i have inconsistencies with the time selector because of time zones.

For now, I can set the PGTZ environment variable when running the grafana client (docker) to render the datetimes in some timezone (and also use select current_setting('TIMEZONE')) but this is not the browser timezone.

Does it make sense?

Thanks so much!
Best
Benoit

Another example: I love to use the plotly plugin (Plotly panel plugin for Grafana | Grafana Labs) to have total freedom on rendering via javascript & plotly.js, beyond stock Grafana visualization.

If I want to generate some “placeholders” for values in my query (that will then be ultimately joined and values returned for the plotly visualization), then:

select * from generate_series(date_trunc('day', $__timeFrom()::timestamp),
                     date_trunc('day', $__timeTo()::timestamp ),
                     '1 day')

returns (for example):

2022-05-06 20:00:00
2022-05-07 20:00:00
2022-05-08 20:00:00
2022-05-09 20:00:00

Instead, with

select * from generate_series(date_trunc('day', $__timeFrom()::timestamp at  time zone 'EDT'),
                     date_trunc('day', $__timeTo()::timestamp  at time zone 'EDT'),
                     '1 day')

The answer in Grafana is correctly:

2022-05-07 00:00:00
2022-05-08 00:00:00
2022-05-09 00:00:00
2022-05-10 00:00:00

(but i need to replace EDT with the browser timezone)

Note that this use of “placeholders” is also very useful if I want to display data in a conventional Grafana table while being sure to include metrics for all days (e.g., with a full outer join), even if there was no data whatsoever for that day in the database (i.e. not caught by a group by)

Hi,

What do you think?
Any query trying to create placeholders timebuckets between __from and __to (e.g., for a simple Table visualization) could not do that correctly without having access to the timezone, no?

Thanks!
Best
Benoit