problem description
aggregates data in a specified format into a specified format
related codes
{
"_id" : "10.182.135.21_CPU_20180627200000",
"parameter" : {
"CPUUtil" : [
{
"time" : ISODate("2018-06-27T12:07:19.000+0000"),
"value" : 15.0
},
{
"time" : ISODate("2018-06-27T12:08:24.000+0000"),
"value" : 0.0
},
{
"time" : ISODate("2018-06-27T12:09:29.000+0000"),
"value" : 0.0
}
]
}
}
{
"_id" : "10.182.135.21_CPU_20180627210000",
"parameter" : {
"CPUUtil" : [
{
"time" : ISODate("2018-06-27T13:07:01.000+0000"),
"value" : 0.0
},
{
"time" : ISODate("2018-06-27T13:08:06.000+0000"),
"value" : 2.0
},
{
"time" : ISODate("2018-06-27T13:09:11.000+0000"),
"value" : 0.0
}
]
}
}
what result do you expect? What is the error message actually seen?
first aggregate into an object, which contains two parameters "time" and "value", both of which are in the form of an array; secondly, convert the time format ISODate to the form of "yyyy-MM-DD HH:mm:ss"
{
"time": [
"2018-06-27 12:07:19",
"2018-06-27 12:08:24",
"2018-06-27 12:09:29",
"2018-06-27 13:07:01",
"2018-06-27 13:08:06",
"2018-06-27 13:09:11"
],
"value": [
15.0,
0.0,
0.0,
0.0,
2.0,
0.0
]
}