Search code examples
prometheuspromql

What is the difference between last_over_time() and instance vector?


last_over_time(metric{}[1h]) returns the latest (recent) sample of samples' set in 1 hour (now - 1 hour) metric{} instant vector returns the latest (recent) sample of samples' set.

These samples would be equal, am I wrong?

When to use the last_over_time and just instant vector?


Solution

  • Prometheus stops returning time series if the distance between the latest sample and the requested timestamp exceeds 5 minutes by default. It may also stop returning series with more recent samples if there are staleness markers exist after these samples - see these docs for details.

    So, basically, metric_name query is somewhat equivalent to last_over_time(metric_name[5m]). These queries may return different results if the requested series contain stale markers.