I have below JSON in mongoDB:
“browsingHistory” : {
“connectionStatus” : {
“totalViews” : “200”,
“othersTotal” : “2”,
“timeStamp” : “2019-05-05 00:00:00”
},
“connectionPaymentOption” : {
“totalMinDue” : “20”,
“totalOthersAmnt” : “10”,
“othersTotal” : “5”,
“timeStamp” : “2019-05-05 00:00:00”
},
“connectionEnrollAmount” : {
“totalEnrollAmount” : 0,
“timeStamp” : “2019-05-05 00:00:00”
}
}
I have to convert this data into a format that grafana accepts and draws a chart.
What way should I write query in mongo. I tried
db.test.aggregate([
{ “group": {
"_id": "_id”,
“cnt” : { “$sum” : 1 }, “ts” : { “$max” : “$ts” }
}}
])
but nothing seems to work, please help.
I am using JAmes Osgood MongoDb plugin.
Appreciate your help, thanks