我管理我的電腦的時間序列數據MongoDB中的格式爲:
聚集在時間序列數據在MongoDB中
- 我創建爲每個服務器一個小時的文檔。
- 然後我試圖以下面的格式存儲每分鐘的cpuMetric數據。
問題是我不知道如何使用cpuMetric中的數據進行聚合。
作爲更具體的我想從這個文件得到最後10分鐘的數據。
{ "_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 }
}
}
在此先感謝!
你想「得到最後十分鐘」怎麼樣?把它們加起來?平均他們?只列出它們?請解釋。 –
對不起,我沒有清除結構。 cpuMetric.0表示第0分鐘數據,同樣cpuMetric.59表示第59分鐘數據。現在我想列出cpuMetric [49:59]。 –
我明白如何閱讀它。我要求「你」告訴「我們」你想如何「使用這些數據」。你所說的只是「得到最後十分鐘」。但那麼做什麼呢? –