# Timestamp of last metric change

**URL:** <https://discuss.prometheus.io/t/timestamp-of-last-metric-change/108>\
**Category:** PromQL\
**Created:** [March 30, 2021, 8:09am UTC](https://discuss.prometheus.io/t/timestamp-of-last-metric-change/108 "2021-03-30T08:09:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![yanick](https://avatars.discourse-cdn.com/v4/letter/y/85f322/32.png) [@yanick](https://discuss.prometheus.io/u/yanick)\
**Post date:** [March 30, 2021, 8:09am UTC](https://discuss.prometheus.io/t/timestamp-of-last-metric-change/108/1 "2021-03-30T08:09:55Z")

</div>

Hi all,

I am using Grafana and prometheus and I am trying to get the timestamp at which a given metric last had it’s value changed. Based on information found here : [https://stackoverflow.com/questions/54148451/get-time-that-passed-since-the-last-increase-of-prometheus-counter](https://stackoverflow.com/questions/54148451/get-time-that-passed-since-the-last-increase-of-prometheus-counter), I tried several queries in prometheus server interface like :

`timestamp(changes(up{job="prometheus"}[1h]) > 0) * 1000`

But I cannot figure out how to get the timestamp at which my metric last changed it’s value.  
I either get query execution errors when trying to filter results, or end up getting the timestamp of the last time the metric was scraped.

Can someone tell me if this is possible using PromQL. Or if there is a way to do this in Grafana ?

---

<div class="post-metadata">

**Author:** ![BrivinTech](https://dub1.discourse-cdn.com/flex017/user_avatar/discuss.prometheus.io/brivintech/32/964_2.png) [@BrivinTech](https://discuss.prometheus.io/u/BrivinTech)\
**Post date:** [May 5, 2024, 3:11am UTC](https://discuss.prometheus.io/t/timestamp-of-last-metric-change/108/2 "2024-05-05T03:11:23Z")

</div>

@yanick Did you got the solution… Asking after 3 years… Hope you didn’t forge the answer

---

<div class="post-metadata">

**Author:** ![punkrockpolly](https://dub1.discourse-cdn.com/flex017/user_avatar/discuss.prometheus.io/punkrockpolly/32/1068_2.png) [@punkrockpolly](https://discuss.prometheus.io/u/punkrockpolly)\
**Post date:** [October 30, 2024, 10:40am UTC](https://discuss.prometheus.io/t/timestamp-of-last-metric-change/108/3 "2024-10-30T10:40:52Z")

</div>

I’m also running into this issue. I have a counter metric that only fires in rare cases. I want to compare the last timestamp of a non-null value for this counter to a different ts. Have been trying all kinds of operators and functions and like the original poster, end up with a vector of ts of the last scrape or query errors.
