MongoDB aggregate query (MongoDB Data Source)

Hi,

I’m trying to create a Time series chart.
The aggregation code runs well in mongo shell:

db.dbStats.aggregate([
{
“$group”: {
“_id”: {
“yearMonthDay”: {
“$dateToString”: {
“format”: “%Y-%m-%d”,
“date”: “$createDate”
}
}
},
“totalSpace”: { “$first”: “$fsTotalSize” },
“usedSpace”: { “$first”: “$fsUsedSize” }
}
},
{
“$project”: {
“_id”: 0,
“time”: {
“$dateFromString”: {
“dateString”: “$_id.yearMonthDay”
}
},
“usedSpacePercentage”: {
“$divide”: [“$usedSpace”, “$totalSpace”]
}
}
}
]);

But when in Grafana using the MongoDB Data source it will generate:
error parsing aggregate args - invalid character ‘)’ after array element

What can that be…?

Thanks much,
Flyhigh

Hi Flyhigh, I had the same issue a while ago. Just delete the “;” in the last line and it should work.