user10000
user10000

Reputation: 207

Grafana adds the timezone difference to dates

I recently started using Grafana to show data I have in my PostgreSQL Database. Now I've reached a point where when selecting data and using a certain timestamp field as the "time" field in Grafana, the data that's shown is the dates + timezone difference.

For example: My data has the timestamp "2020-08-24 12:05:30" and my timezone is UTC+3, but Grafana shows it as "2020-08-24 15:05:30".

Is there any way to simply display the data as it exists in my DB without adding that timezone difference?

Upvotes: 7

Views: 8460

Answers (4)

Sergej Isaev
Sergej Isaev

Reputation: 1

It helped me to cast the type right in the request: valid_for_dttm::timestamptz at time zone 'UTC'

Upvotes: 0

Martin
Martin

Reputation: 1003

The way I think it is intended to be used is:

Storing of dateTime values in the database should be in UTC only. (E.g. send a string representation of datetime.datetime.utcnow() to PostreSQL).

If you then select your timezone in Grafana's settings, things should work as expected.

Upvotes: 0

Jasper
Jasper

Reputation: 23

Changing the timezone wasn't my solution, as it would also shift "now". I simply added an interval to my query:

TO_TIMESTAMP(DateTime, 'YY-MM-DD HH24-MI-SS') - interval '2 hour' as time

to shift it 2 hours

Upvotes: 1

Atorian
Atorian

Reputation: 817

Go to the dashboard settings and make sure the timezone is set to UTC or whatever timezone is used by the data.

Grafana dashboard settings

Upvotes: 5

Related Questions