I would like to define a Variable of Query type from the MongoDB data source.
For this reason, I created a sample database trial_db
and a table trial_table
, with the following items:
[{
"name": "A",
"value": 5.3
},{
"name": "A",
"value": 5.8
},{
"name": "A",
"value": 6.2
},{
"name": "B",
"value": 6.8
},{
"name": "B",
"value": 1.2
}]
I would like to create a Grafana Variable from the distinct name
fields (A
and B
in this case).
So, in the Query field of this variable, I selected the MongoDB data source, and inserted trial_db.trial_table.distinct("name")
as query. It is not working: the “Preview of values” is None
. And in the dashboard, the new variable appears, but I can only select None
. So, this variable is not working, and I suspect that I am somehow misusing the MongoDB data source for this use case.
The MongoDB plugin works very well as a data source for panels, but it is not working for the definition of Variables.
What should I do? Is the MongoDB plugin supposed to work for the definition of Variables?
I am using Grafana 9.1.5.