Finding timestamp of min (or max) reading

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.

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

min_over_time(temp[12h])

looks like this:


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!

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