-
Notifications
You must be signed in to change notification settings - Fork 156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add previousN and nextN to range #702
Comments
This would be a great addition and it would solve issue#6878 as mentioned by @vdwpsmt. Without it storing data with irregular intervals (think: events) using influxdb makes no sense. |
openHAB is using following as workaround:
Using the following influxdb1 query was much more performant:
|
Suppose the size of the "ElectricMeter_Total" measurement is 1GB for the last 100y. Would the query above indeed have to browse through and sort 1GB of data before getting to the result?? That doesn't sound very efficient. Surely there is some optimization build in InfluxDB that prevents such inefficiencies? |
This feature request would also help to fix the values that |
I have tried to solve this with:
But notice the
So asside of that it's wildly inefficient to go through the last 50+ years of data (1970 - 2202), it also doesn't work. And if window fuctions were to be used after the So there really needs to be an efficient way to include the previous value in the query. And the proposed change here looks to be the most efficient one. |
@SGStino I want to mention that I made a time-series database myself (before starting to use InfluxDB). |
It's a workaround that works for some cases in grafana: if you select absolute timestamps, and the range isn't to big, because window functions can't be used. I guess this should work with the 24h:
however it seems to complain about "sub" from the package date:
EDIT: nevermind, this works great (and fast) in 2.4, sub didn't exist in 2.0 and i didn't upgrade my test instance ... |
I will definitely try that. |
when you set the timerange to But I seem to have been mistaken, Grafana doesn't do this, it's the Influx's built-in dashboard. |
Is there a reason to map the last value to the beginning of the timerange? But maybe there's a limitation how far outside a value can be to be still used for the drawing engine ... |
Btw. this is also useful with date.add on the timeRangeStop when looking at time ranges that doesn't stop at now(). One last point that needs to be solved to satisfy my perfect self: This was quite easy in SQL and I start regretting my switch over to Flux. :P |
Ok, that way it works for me. For the sake of simplicity, I load the complete data of a few hours before and after the current timespan instead using multiple queries. I also requested data after the timespan in case you scrolled back in Grafana, to fill the end of the graph. And at the end, I look for the last value that the sensor sent, and move it to "now()".
|
This issue has had no recent activity and will be closed soon. |
It's very common for users to want to get a range of data, but to also pull back some number of points before or after the time range specified. For example, query from
2018-06-15T11:47:00
to now and include the 3 points that occur before the start time. The default values for previousN and nextN should be 0. The function signature would look like:range = (start, stop=now(), previousN=0, nextN=0)
The text was updated successfully, but these errors were encountered: