Created
September 21, 2014 18:05
-
-
Save vparihar01/d47867d38c2921e0468d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
db.notifications.aggregate({ "$group" => { | |
"_id" => { | |
"nagios_hostname" => "$nagios_hostname", | |
"nagios_state" => "$nagios_state", | |
"nagios_service" => "$nagios_service", | |
"nagios_epoch" => "$nagios_epoch" | |
}, | |
"stateCount" => { "$sum" => 1 } | |
}}, | |
{ "$group" => { | |
"_id" => "$_id.nagios_hostname", | |
"notifications" => { | |
"$push" => { | |
"state" => "$_id.nagios_state", | |
"count" => "$stateCount", | |
"service" => "$_id.nagios_service", | |
"date" => "$_id.nagios_epoch" | |
}, | |
} | |
}}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment