influxdb query period of time where value is changed

I’ve a table called test on InfluxDB. One of the columns called is_up which indicates if some type of service is up or not. Possible values are

1 --> Up
0 --> Down

Now the data looks something like

2019-01-01T00:00:00Z ---> 1
2019-01-01T00:01:00Z ---> 1
2019-01-01T00:02:00Z ---> 0
2019-01-01T00:03:00Z ---> 0
2019-01-01T00:04:00Z ---> 0
2019-01-01T00:05:00Z ---> 1
2019-01-01T00:06:00Z ---> 1

The above data indicates that the service was down for 3 minutes between 2019-01-01T00:02:00Z and 2019-01-01T00:04:00Z. Currently I’ve the following query, which gives a list of downtimes.

SELECT * FROM test WHERE is_up=0 and type = 'myservice' and time < now() and time > now() - 30d

What would be the proper query to find the time range(Start and end time) of downtimes.