Search code examples
influxdb

InfluxDB - Getting only last value in query


Is possible to query only for the last value (or n-th value) of the results of a query?

For example, in the query:

SELECT value FROM response_times WHERE time > now() - 1h limit 1000;

Is possible to get only the last value, i.e. the one more far ago in time (possibly the 1000-th element)?

Of course I can retrieve them all and then skip to the last one, but I don't want to waste bandwith this way.


Solution

  • In the API, have a look at first/last to select the first or last record of a column. You also have top/bottom to select more than one record

    [edit] top/bottom seem to return higest/lowest values of the time frame