I’m using Grafana cloud with the MongoDB plugins and am trying to use a dashboard variable in a MongoDB query to populate a table. My variable is named _comp and is successfully being populated in a dropdown. My query looks like
design_summaries.summaries.aggregate(
[{
$replaceRoot: {
newRoot: "$Components"
}
}, {
$project: {
NumberOfComponents: {
$size: "$XXXXXXXX"
}
}
}, {
$group: {
_id: null,
avgAmount: {
$avg: "$NumberOfComponents"
},
maxAmount: {
$max: "$NumberOfComponents"
}
}
}, {
$project: {
_id: 0
}
}]
)
and I’d like to replace the XXXXXXXX ( just that part, keeping the preceeding $ ) with the value of the variable. I’ve tried ${_comp}, [[_comp]] and other various combinations but have not been successful in replacing that portion of the query with the variable. I’m guessing it has something to do with the fact that the query itself uses $.