In the flux language help for last-function is this example:
from(bucket:"example-bucket")
|> range(start:-1h)
|> filter(fn: (r) =>
r._measurement == "cpu" and
r._field == "usage_system"
)
|> last()
How this can be modified if I don’t want to use the start time in the range-function? If I remove the range-function from the query it doesn’t work. Using value -inf as a start time seem to work but is there more elegant way to make this work in all the cases? Also if some on could explain why the range-function is needed to make this query work would be great.
I’m working on influxdb 2.0.0 with python influxdb_client 1.12.0.
Hello @Jani_Kallankari,
The range function is needed to help ensure that users are querying intelligently. Typically most users don’t want to return all of their data/100 millions of points. What do you think would be a more elegant solution?
As I see the range is kind of filter to data and most logical is to get all data if no filter is applied. Sure some times you might get huge data but isn’t it what you asked for? In the example case there is last()-filter which will limit the data so there really is no need for double filtering. If there are these kind of mandatory filters it would be good to be highlighted it in manuals as it confuses newbies.
Just my three cents
range is required. I believe this is valid:
|> range(start:0)