Variable not showing anything "Preview of values"

Hi,

I am trying to use a dashbaord based on mongodb-exporter.

I used dashboard id 12079 from Grafana labs, and on one of my environments it worked fine, and I can see the definition of the variable “env” is showing in the “preview of values” the correct host:port.

tthe query for the variable is:
label_values(mongodb_connections, instance)

–uploaded is a screenshot for this environment

When I import the same dahsboard to another environment, I can see that the “preview of values” for the same variable is empty.
Hence of course all panels based on this variable are empty.

If I check the metrics for this exporter, thee seem fine. For example:

$ curl -s http://localhost:9216/metrics | grep connections
# HELP mongodb_connections The connections sub document data regarding the current status of incoming connections and availability of the database server. Use these values to assess the current load and capacity requirements of the server
# TYPE mongodb_connections gauge
mongodb_connections{state="active"} 53
mongodb_connections{state="available"} 838694
mongodb_connections{state="current"} 166

also, for other queries entered into an empty panel, even though the job shows “success” the array shows [0] and the pannel is empty.

again, the metric for the same query retruns result fine:

Object

request:Object

url:"api/datasources/proxy/1/api/v1/query_range?query=mongodb_mongod_replset_member_uptime&start=1634719890&end=1634806290&step=30"

method:"GET"

hideFromInspector:false

response:Object

status:"success"

data:Object

resultType:"matrix"

result:Array[0]

How can I debug why the same query/metric does not work inside Grafana?

Grafana version (containerized) is 7.2.2
Prometheus version (containerized) v2.22.0


Thanks,
Tamar

Looks like there isn’t a label named instance which is why it is not returning anything. Based on your query, it looks like the only label for the mongodb_connections metric is state.

Well, i am still not sure why it worked in one environment and not the other, but apparantly adding labels to mongodb_exporter in the promethues.yml solved the problem, as posted in here:

“Please add additional labels for mongodb_exporter targets. Such labels are generated in PMM2 and used in dashboards formulas. e.g. node_name: nodeWithMongo1 service_name: mongo1 cluster: myCluster replication_set: repl1 service_type: mongodb”

same issue i faced
please find attached screen shot