grafana-prtg icon indicating copy to clipboard operation
grafana-prtg copied to clipboard

All Panel 1 hour trouble

Open g3rhard opened this issue 7 years ago • 6 comments

Hello everyone. When I add any panel (graphs, single stat), the value is reflected in the time specified in the "time range" minus one hour.

screenshot_15

Grafana 4.3.1 PRTG API version: 16.4.27.7140+

g3rhard avatar Jul 11 '17 05:07 g3rhard

Not sure about this. UTC, last two hours works fine here. Which version of plugin, which version of grafana? This looks like an issue with not enough datapoints. Are you in the same timezone as the server? if not, how many hours is the difference?

neuralfraud avatar Jul 15 '17 23:07 neuralfraud

I have what might be the same issue in the opposite direction. I'm in a timezone one hour behind where my grafana server lives and my graphs are off an hour.

It's 12:00 locally: image

Here's a screencap provided by a user in the same time zone as the server. Notice there's more data, not just a time offset. image

Liquidmantis avatar Jul 17 '17 18:07 Liquidmantis

@Liquidmantis I'm not sure how to solve this in code, because PRTG requires date format "YYYY-MM-DD-HH-MM-SS" and there seems to be no way to specify time zone/UTC. The time is determined by the browser.

You could, however, use Grafana to manipulate the timezone by editing the dashboard itself,

image

If your time is one hour behind the server, ,instead of selecting "now-1h", try "now+1h"

neuralfraud avatar Jul 18 '17 04:07 neuralfraud

@neuralfraud Sorry, I dropped the ball on this. The Now+1h tweak does get all the data, albeit with a padded hour of blank data on the timeline. We just tested setting the API user's timezone to be my TZ (Mountain time, UTC -7) and everything was displayed correctly. However, the bulk of our team is in Central time, the same as our PRTG and Grafana servers, so I'm getting outvoted on that fix. We also have global team members so they're in similar situations.

Liquidmantis avatar Aug 16 '17 03:08 Liquidmantis

Hello @neuralfraud,

I was looking over this and I believe that I have a viable way for this to be resolved through code. In PRTG the timezone of the historical data API call is configured in the user configuration.

Knowing that i think you can request this information on the datasource configuration, or you could also do a web query for it, but i don't see the point of constantly querying for it when you can ask for it, and once you have the timezone information then it's just a matter of converting the date before sending it on the API call. Since you are already sending all dates through getPRTGDate() for formatting it shouldn't be very difficult to convert it to the server timezone there.

I was going to try to implement this myself, but I'm not familiar enough with the code itself, so it would take me longer than the time I have for this project.

Jonatan-B avatar Aug 16 '17 16:08 Jonatan-B

Hi @neuralfraud,

we had same issue and I fixed it by using UTC getters at line https://github.com/neuralfraud/grafana-prtg/blob/master/jasonlashua-prtg-datasource/dist/PRTGAPIService.js#L88 since our PRTG user uses UTC. I am not familiar with PRTG API, but if it isn't possible to get user timezone as @Jonatan-B mentioned, maybe this could be the fix with additional constraint that PRTG user (which you specify in datasource configuration) needs to also use UTC. My change:

var str = [dt.getUTCFullYear(), this.pad(dt.getUTCMonth(), true), this.pad(dt.getUTCDate()), this.pad(dt.getUTCHours()), this.pad(dt.getUTCMinutes()), this.pad(dt.getUTCSeconds())];

goran-rumin avatar Sep 14 '18 10:09 goran-rumin