I have multiple server instances that are exporting various metrics. Frequently, some instances are offline, therefore, they don't export anything.
I would like to create a panel that would simply display a table in which each server instance is represented by a row and states how long (hh:mm) the server has been offline (i.e. a duration between last exported datapoint in a series and now).
Example output:
instance | offline_duration
----------------------------
instance1 | 00:00
instance2 | 01:12
instance3 | 25:10
I have multiple other use-cases in which I would appreciate both the ability of selecting the last value (of all times) and measuring time duration from now to the series data point.
Semantically, I was hoping for something like now() - timestamp(last_over_time(my_metric))
but this has a lot of obvious problems such as last_over_time
requires a range-vector.
Is this even possible? Thank you for your help!
This seems to be possible with subquery:
time() - (
max_over_time(
( timestamp(your_metric) )[2h:1m]
)
)
2h
here is the time window - how far into the past query should look for last data point