Druid aggregations

Hi,

I am using druid for a huge data about about 20 billion records in an hour of different systems status. Now I have to store this data on hourly and create an report at the end of the day or we can say I have to prepare daily report from these records. So I am performing group By on this at end of the day, So I am able to get the normal aggregations which is on the druid like sum,last,min,max easily. But I have one custom aggregation requirement. In which the my application store data in druid as metric, the metric contains the positive value if system is up and 0 if the system is down in that hour. So Now in daily report I have to send them count of how many times system goes down and comes up. For example i get metric data as :
Time Metric Systems ID
00:00 50 1
01:00 80 1
02:00 90 1
03:00 50 1
04:00 0 1
05:00 0 1
06:00 0 1
07:00 0 1
08:00 20 1 //Becomes count=1
09:00 50 1
10:00 70 1
11:00 60 1
12:00 100 1
13:00 30 1
14:00 0 1
15:00 0 1
16:00 0 1
17:00 0 1
18:00 0 1
19:00 50 1 // Now count=2
20:00 70 1
21:00 0 1
22:00 0 1
23:00 90 1 // Now count=3

So In this data total 3 times value comes from 0 to some positive value.
So please guide me how to develop this aggregation in druid. Since it requires the time based sorting as well as the complete list to calculate system down-up time count. I also can’t run in single thread group by as well as it is over 20 Million records and I have SLA of 45 Min. only. Please help me ASAP.

Cluster config for druid we have:
Overlord - 1 Machine
Broker - 2 Machine
MiddleManager - 3 Machine
Historical - 10 Machine
Corddinator - 1 Machine
Metastore Mysql - 1 Machine

Each Machine configuration
RAM - 64 GB
No. of Core - 64
HDD - 1TB