How to calculate the time a service has been up using promql?

Hello!

I have a service that returns status 1 if the application is up, or status 0 if the application is down. I’m trying to have a graph in grafana that shows the the total time the application is online at a stretch. For example, if the application is running for 3 hours straight, then the grafana visualization should have a “triangle” where the peak is at number 3, and then the line should go down to 0 if the application went down. And then if the application is back up again after 5 hours, then the line should again go up.

So far, I’ve tried using sum_over_time, but I that’s just for adding up the values.

How can I the result I’m trying to achieve? Thanks in advance!