Grafana and the influxdb timeShift() function

Hi Openhabians,

after some research, a timeShift function seems to be available with influxdb - but I can’t get it to work. Here’s what the docs say - does this not apply to influxdb (1.8.x)?

I am trying to shift some queries in Grafana by a certain time duration. I know Grafana has the time shift in the query options, but that is always applied to all of my queries. In this case I want to shift one query by a certain amount of time, but not all.

Has anyone an Idea how the query should look like? I tried to add timeShift(duration: -7d) to my query (at the end) with no success.

Thanks for your help!

All the best,

Rob

Given that this is wholly outside of openHAB, you are more likely to get an answer on an InfluxDB forum or perhaps a Grafana forum. We have some users of InfluxDB on this forum but for the most part the vast majority of the experience does not extend beyond configuring it and openHAB to use it for persistence.

Looks like that’s a function of Flux (as opposed to influxql, the ‘standard’ query language for influxdb). First thing to check is that you’ve enabled Flux, as outlined in https://docs.influxdata.com/flux/v0.65/introduction/installation/.

You then want to install the flux addon for grafana (note that it’s in beta) which should allow you to use the flux query language - https://grafana.com/grafana/plugins/grafana-influxdb-flux-datasource.

Once that’s done I believe you should have access to the time shift function. I’ve never used flux before so hopefully the above works but I can’t make any guarantees.

Thanks so much for your answers. So I got it working using:

I didn’t notice the timeShift function was for FLUX and not influxQL - out of curiosity I will tr the flux path as well!

All the best,

Rob

2 Likes