I have MongoDB documents like the ones explained here https://www.mongodb.com/blog/post/schema-design-for-time-series-data-in-mongodb
So 1 document for each day (and type and system) with a values field that contains hours, minutes and seconds data, so like this:
{
"_id" : ObjectId("59fc57d75bc7315366b78799"),
"date" : ISODate("2017-11-03T00:00:00.000+0000"),
"system" : "192-168-1-30",
"type" : "memory",
"values" : {
[...]
"11" : { // hour 11
[...]
"49" : { // minute 49
[...]
"43" : NumberInt(62171000), // second 43
"44" : NumberInt(62169000),
[...]
},
"50" : {
"1" : NumberInt(62363000),
"2" : NumberInt(62319000)
[...]
},
[...]
},
[...]
},
"updatedAt" : ISODate("2017-11-03T13:34:00.720+0000"),
"createdAt" : ISODate("2017-11-03T11:49:43.442+0000")
}
Here for example at 11:49:43 of 2017-11-03 memory was at 62171000.
Now I'm trying to get aggregated data of these documents to obtain rows with average data for each minutes, hours and so on but I'm confused how to tell to the aggregation framework that $values is an array of hours, minutes and seconds.
Or should I use map/reduce?
Any hints?