aclowkay
aclowkay

Reputation: 3897

Prometheus get last value recorded for metric

I'm not sure if it's possible, i'd be happy know if it's the case, but:

Let's say I have a metric, that was last seen 14 days ago. How can I query prometheus for the last value over a specific range (i.e. 30 days) and what was its date??

Upvotes: 4

Views: 11183

Answers (2)

soltiz
soltiz

Reputation: 304

Since 2.2.0(March 2021) prometheus release, 'last_over_time' allows you to retrieve exactly what you need:

last_over_time(my_metric[14d])

Docs: https://prometheus.io/docs/prometheus/latest/querying/functions/#aggregation_over_time

Upvotes: 7

fifoq
fifoq

Reputation: 203

Seems that you are looking to obtain the raw metrics which Prometheus has in it's store from a range of time. extracting raw samples from prometheus.

Upvotes: 1

Related Questions