I am managing my PC time-series data in MongoDB in the format as :
- I am creating a document for each server for an hour.
- Then i am trying to store cpuMetric data for each minute in the format as shown below.
The problem is that i don't know how to use the data inside cpuMetric in aggregation.
Being more specific i want to get the last 10 minutes data from this document.
{ "_id" : "192.168.xxx.xxx1440yyy000",
"time" : ISODate("2015-yy-xxT05:30:00Z"),
"ip" : "192.168.xxx.xxx",
"serverId" : "abc",
"cpuMetric" : {
"0" : { "usage" : 25.99, "process" : 123, "cores" : 4, "speed" : 2394, "uptime" : 45839 },
"1" : { "speed" : 2394, "uptime" : 45899, "usage" : 26.003333333333334, "process" : 121, "cores" : 4 },
.
.
.
"58" : { "usage" : 26.093333333333334, "process" : 119, "cores" : 4, "speed" : 2394, "uptime" : 45959 },
"59" : { "usage" : 26.73, "process" : 119, "cores" : 4, "speed" : 2394, "uptime" : 46019 }
}
}
Thanks in advance!!