Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Most recent value or last seen value

Tags:

prometheus

Prometheus is built around returning a time series representation of metrics. In many cases, however, I only care about what the state of a metric is right now, and I'm having a hard time figuring out a reliable way to get the "most recent" value of a metric.

Since right now it's getting metrics every 30 seconds, I tried something like this:

my_metric[30s]

But this feels fragile. If metrics are dated any more or less than 30 seconds between data points, then I either get back more than one or zero results.

How can I get the most recent value of a metric?

like image 833
Cory Klein Avatar asked Nov 21 '16 21:11

Cory Klein


1 Answers

All you need is my_metric, which will by default return the most recent value no more than 5 minutes old.

like image 122
brian-brazil Avatar answered Sep 18 '22 15:09

brian-brazil