Graphs does not show the data correspoding to current time zone

Hi

I am user of Open source version of Graphana. I had downloaded the source code and installed it in on Linux box and it works fine.

I am currently using Grafana for visualizing data from a bunch of electrical sensors connected to a gateway. I collect data from sensor and store them into a influx database which is running on the same Linux box. Sensor data is stored in time series format. Using influx db query I am able to verify that the stored data.

Grafana as a visualization software is working fine. But issue I am facing is with Graphs. (Not with other panels)

The X-axis does not show the current time, instead is show the current time at UTC and display the data corresponding to it. I had checked my machine time at it is correct.

To describe the problem in a bit detail

  1. Let us say, I had set the timezone at UTC (Settings->Time Options-> Timezone) Though, I am currently at GMT + 5:30 hours. (India)

Now assume, current time is 20:00 (8:00 PM) Graphan (graphs) will display the data corresponding to 14:30 (2:30 PM). In other words the Graphs show the x-axis which exactly 5:30 hours behind and the data corresponding to that time point. I have Gauge widget to display the current data. It is displaying the correct values corresponding to current time.

  1. Let us says I had set timezone to “Local Browser time” the behaviour changes this time. Now the X-axis shows the current time. IF the current time is 20:00 It shows the time scale from 14:30 (2:30 PM) to 20:00 (8:00 PM) which is perfect. However the data it shows corresponds to a given time point, is exactly 5:30 hours behind. That means if I am looking at data point correspoding to 20:00 it will be showing the data that was collected against the time 14:30 (exactly 5:30 hours back). Here there is mis match between X-values and the corresponding value on Y-axis.

To debug the problem:

(i) I had checked the local machine where browser is running (It is windows machine) and its time zone is correctly set to UTC + 5:30 PM. I checked the time zome and clock on the Linux box where Grafana and Influx is installed that is also correct.

(ii) The influx database query I am using to pull data to Grafana is
SELECT “Humidity” FROM “defaultdb”.“autogen”.“ClimateEvents”
When I run this query in Influxdb prompt it shows correct values

(iii) I checked through Query inspector there also the data is correct.

(iv) I had checked the defaults.ini file I did not see anything related to Timezone settings.

Can you help me to sort out this issue ?
I am using Internet explorer for accessing Graphana

Regards
Girish

I doubt you are looking for an answer to this after all this time, but since I just started using Grafana today and ran into the same problem I thought I would throw this out.

Grafana needs the times to be in UTC. You need to either store them in UTC in your database or convert them in the query.
Assuming influx is using SQL (I’m using mysql as a data source):
You need something like this:
SELECT CONVERT_TZ( NOW(), @@session.time_zone, ‘+00:00’ )

NOW() above would be changed to your date field in your database.

1 Like

I had resolved the problem. Earlier I was explicitly mentioning time stamp in the json format as below.
json_body = [
{
“measurement”: “brushEvents”,
“tags”: {
“user”: “Carol”,
“brushId”: “6c89f539-71c6-490d-a28d-6c5d84c0ee2f”
},
“time”: “2018-03-28T8:01:00Z”,
“fields”: {
“duration”: 127
}
},
{
“measurement”: “brushEvents”,
“tags”: {
“user”: “Carol”,
“brushId”: “6c89f539-71c6-490d-a28d-6c5d84c0ee2f”
},
“time”: “2018-03-29T8:04:00Z”,
“fields”: {
“duration”: 132
}
},
{
“measurement”: “brushEvents”,
“tags”: {
“user”: “Carol”,
“brushId”: “6c89f539-71c6-490d-a28d-6c5d84c0ee2f”
},
“time”: “2018-03-30T8:02:00Z”,
“fields”: {
“duration”: 129
}
}
]

When I removed the time field from this and allowed influx to use the current time as timestamp grafana started showing current time. The json format is as below

json_body = [
{
“measurement”: “brushEvents”,
“tags”: {
“user”: “Carol”,
“brushId”: “6c89f539-71c6-490d-a28d-6c5d84c0ee2f”
},

    "fields": {
        "duration": 127
    }
},
{
    "measurement": "brushEvents",
    "tags": {
        "user": "Carol",
        "brushId": "6c89f539-71c6-490d-a28d-6c5d84c0ee2f"
    },

    "fields": {
        "duration": 132
    }
},
{
    "measurement": "brushEvents",
    "tags": {
        "user": "Carol",
        "brushId": "6c89f539-71c6-490d-a28d-6c5d84c0ee2f"
    },

    "fields": {
        "duration": 129
    }
}

]

BTw I using python wrapper to influx for wrting to influx. Reference is here

https://www.influxdata.com/blog/getting-started-python-influxdb/