# Finding timestamp of min (or max) reading

**URL:** <https://discuss.prometheus.io/t/finding-timestamp-of-min-or-max-reading/1301>\
**Category:** PromQL\
**Created:** [November 17, 2022, 12:55pm UTC](https://discuss.prometheus.io/t/finding-timestamp-of-min-or-max-reading/1301 "2022-11-17T12:55:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![grifferz](https://avatars.discourse-cdn.com/v4/letter/g/7c8e57/32.png) [@grifferz](https://discuss.prometheus.io/u/grifferz)\
**Post date:** [November 17, 2022, 12:55pm UTC](https://discuss.prometheus.io/t/finding-timestamp-of-min-or-max-reading/1301/1 "2022-11-17T12:55:10Z")

</div>

I’m trying to find the timestamp for the maximum or minimum reading. From what I understand this is difficult but [a workaround was posted in issue #8966](https://github.com/prometheus/prometheus/issues/8966#issuecomment-874961630).

So let’s say I have a metric called “temp” which is temperature in celsius.

`min_over_time(temp[12h])`

looks like this:

 ![prom1](https://europe1.discourse-cdn.com/flex017/uploads/prometheus/original/1X/f4c6be7f331cd1e0478a4c54c09ea6ae1046dc05.png)  
which is fine; the minimum temperature in the last 12 hours was about 20.8°C. So in following the posted workaround I would want to filter for all values that equal that 20.8:

`scalar(min_over_time(temp[12h])) == temp`

This produces no results. Why? Surely if `scalar(min_over_time())` produced a value, that value should be present for at least one sample?

Also, it doesn’t _always_ produce no results. If I alter the time range then it sometimes produces expected results.

What’s going on? And is there yet a better way to get the timestamp of the max/min value as per that issue?

Thanks!

---

<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:22am UTC](https://discuss.prometheus.io/t/finding-timestamp-of-min-or-max-reading/1301/2 "2024-05-05T03:22:46Z")

</div>

@grifferz Did you get the solution for this? I am facing the same kind of issue now? Please share the solution you got…
