Prometheus data filtered by duration

Hi there,

we’re using Grafana together with Prometheus and windows_exporter on our Remote Desktop Session hosts to monitor a lot of different things.

Altough I’ve already set up a dozen dashboards, I currently can’t figure out how I can achieve to display a table only showing those users, whose sessions are disconnected for at minimum 2 hours in one piece within a selected timeframe.

The windows_exporter metric we already have a timeline set up with to filter the disconnected users, is (for example):

windows_terminal_services_session_info{instance=~“rds.", state=“disconnected”, user=~"domain.”} == 1

Can someone take me by the hand how to accomplish the goal?

Regards,
Andreas