Get Server downtime value

My influxdb has system status as value i.e UP or DOWN. At any given point of time how can i get the total downtime. I need to plot the total downtime in grafana
For example at 16:00 the total downtime is 1 hr 30 minutes
Time Status
10:00 UP
11:30 DOWN
12:00 UP
14:00 DOWN
15:00 UP

There’s an elapsed function that might help you do the calculations.