19 lines
644 B
JavaScript
19 lines
644 B
JavaScript
const mongoose = require('mongoose');
|
|
mongoose.connect('mongodb://backone_inspect:backone_inspect@mongodb.prod.proit.id:27017/backone_inspect_0')
|
|
.then(async (m) => {
|
|
console.log('Aggregating flows...');
|
|
const result = await m.connection.db.collection('flows').aggregate([
|
|
{ $match: { app_label: { $ne: null, $ne: '' } } },
|
|
{ $group: {
|
|
_id: '$app_label',
|
|
download: { $sum: '$download' },
|
|
upload: { $sum: '$upload' },
|
|
flows: { $sum: 1 },
|
|
}},
|
|
{ $sort: { download: -1 } },
|
|
{ $limit: 3 }
|
|
]).toArray();
|
|
console.log(result);
|
|
process.exit(0);
|
|
});
|