-
Notifications
You must be signed in to change notification settings - Fork 15
Description
Issue Description:
I'm having trouble executing a MongoDB aggregation query in Grafana using this datasource plugin. I have two very similar queries:
Query that works in Appsmith:
{
"aggregate": "users",
"pipeline": [
{
"$match": {
"CreatedOn": {
"$gte": "2023-01-25T00:00:00Z"
}
}
},
{
"$group": {
"_id": {
"$dateToString": {
"format": "%Y-%m-%d",
"date": {
"$dateFromString": {
"dateString": "$CreatedOn"
}
}
}
},
"count": {
"$sum": 1
}
}
},
{
"$sort": {
"_id": 1
}
},
{
"$project": {
"_id": 0,
"date": "$_id",
"count": 1
}
}
],
"cursor": {}
}
Query that doesn't return any data in Grafana:
[
{
"$match": {
"CreatedOn": {
"$gte": "2023-01-25T00:00:00Z"
}
}
},
{
"$group": {
"_id": {
"$dateToString": {
"format": "%Y-%m-%d",
"date": {
"$dateFromString": {
"dateString": "$CreatedOn"
}
}
}
},
"count": {
"$sum": 1
}
}
},
{
"$sort": {
"_id": 1
}
},
{
"$project": {
"_id": 0,
"date": "$_id",
"count": 1
}
}
]
Questions:
Why does the full aggregation command (including "aggregate": "users" and "cursor": {}) work well in Appsmith, but the plain pipeline array does not pull any data from the "users" collection in Grafana?
Is the Grafana plugin expecting the full aggregation command structure rather than just the pipeline because it won't work?
Could there be a syntax or format difference that I’m missing when writing queries for Grafana using this plugin?
I'm not sure what I am doing wrong. Any help or clarification on how to properly structure the query for Grafana would be greatly appreciated.
Thank you!