Wrong timefilter

Hello,

I’m having troubles filtering my data with the timepicker (SQL server).

When I try to filter the data by an absolute timerange, it gets filtered like it should.

But when I try to filter the data by a relative timerange (e.g. last 5 minutes) the time range changes to -2h.

How can I add two hours to the relative timefilter? Or is there another possible way to fix this problem?

Thanks!

No, it didn’t change. Query has time condition in UTC (please note that ‘Z’ in timestamp - Z = zero timezone = UTC), so that UTC time is the same as your local PC time (your local PC time is just in different timezone).

The good practice: your data in DB must be in UTC timezone, so client (Grafana) will use UTC to query and then just “move” timestamp to your local or dashboard timezone. If you don’t follow this practice, then expect many time related problems (search this forum for problems: shifted data +/- X hours).

hi,

I would expect that the now instruction takes in account the UTC time settings of the Grafana and not the PC settings. Just like the relative time selection does. Now the two settings behave different from each other.

The problem is that we try to make a dashboard on an existing database where we can not change the data in the tables.

Even if i would change the time setting in my table like the column re_op_endt, the table view doesn’t update this UTC time to the local time zone in the screenshot below.

Enable “table view” (it’s “debug view”):

and check if that column is recognized as time column by Grafana (it can be varchar in the DB, so then it’s not possible to have implicit time recognition on the Grafana level - you have to do that explicitly - cast column to time with Grafana transformation).

You can simple query to check:

SELECT
  re_op_endt::varchar AS varchar,    --- this is varchar, so Grafana doesn't format it at all
  re_op_endt AS orig,                --- if this is proper timestamp then Grafana will use local timezone on it
...

You didn’t provide reproducible example, so there can be a millions of thing which can be wrong/misleading. Play/explore/test/…