MongoDB exporter metrics from multiple mongo instance

I have multiple mongo docker containers in a replication setup. I want to scrape metrics from all three instance using mongodb exporter and prometheus. I already specified the server info in URI like this

mongodb://mongo-0:27017,mongo-1:27018,mongo-2:27019/?replicaSet=rs0

The mongoexporter only scrape information from the first instance only(mongo-0). How to get the metrics from all three instance so I can view the details of all from a single dashboard on grafana

1 Like

Hi, you will need 3 exporters for this. Point each of them to one of the instances instead of using the replica set connection string.

1 Like

May I know how it worked for single server since Its not even working for single server in my case

here is my docker compose file

services:
mongo1:
container_name: mongo1
image: mongo
networks:
- mongo-network
ports:
- 27017:27017

percona:
image: percona/mongodb_exporter:2.37.0
container_name: percona
command: --mongodb.uri=“mongodb://localhost:27017/admin” --collect-all --discovering-mode
networks:
- mongo-network
depends_on:
- mongo1
networks:
mongo-network:
driver: bridge