How do I get the oldest point in a VictoriaMetrics time series?

104 Views Asked by At

What is the equivalent of this InfluxDB query in VictoriaMetrics?

SELECT * FROM ${measurement}
    WHERE ...
    LIMIT 1

VictoriaMetrics doesn't have a LIMIT modifier, so a query like
${metric}{...labels...}[20y]
will return ALL points. (Also, 20y is dicey, but an arbitrarily large duration won't work.)

I only need the timestamp of that point.

1

There are 1 best solutions below

0
Dan Dascalescu On

One answer is tfirst_over_time:

returns the timestamp in seconds for the first raw sample on the given lookbehind window d per each time series returned from the given series_selector.

So,

tfirst_over_time(${metric}{...labels...}[100y])

You still have to supply an arbitrarily large duration, but surprisingly, 100y doesn't seem to bug tfirst_over_time.