How to represent last seen time in Grafana/Prometheus?

I have some battery powered devices that report in irregular intervals that they are still there. When they check in I get a websocket message from their hub with a new last_seen value. I can also query this last_seen value at any time. I can push to Prometheus or let it pull.

The questions I’d like Grafana to answer are usually “Which devices are currently considered up, according to a device-specific timeout, and which down?” and “When was the device up or down within this time span?”. The latter can also be phrased as “When has the device checked in within this time span?”, I could then see the down periods graphically as periods where the are no check-ins.

I’m wondering what’s the best way to represent this information in Prometheus/Grafana. Should I push the last_seen timestamp as a UNIX timestamp as a metric value? Should I just send a metric up with a value of 1 whenever I receive a check-in? Some other format I haven’t considered?

Hey @andrekr, if you push an up based metric of boolean value, it would help you to have a cleaner graph.

If you try to display the timestamp value in the metric itself, it’s better to have a stat type panel, and then you can display the timestamp itself as last seen value.

I’d suggest going with the boolean based metric since you can easily see historic data when it was down.