Best Practice for running PMM Client for MongoDB ReplicaSet

Hi Team. Thanks a lot for this awesome PMM tool. Great Work.

I am trying to monitor a mongodb replicaset. I understand steps to setup a mongo client (on Ubuntu node) is

  1. Install pmm2 repo. (apt install).
  2. Configure PMM client to talk to PMM server (pmm-admin config ...
  3. Create role and user in mongodb. (db.createRole & db.createUser)
  4. Create a PMM service for this mongodb. (pmm-admin add mongodb).

My question is reg fourth (4th) step. Do we need to do this for all the nodes of replicaset. Or should this be done only once for one replicaset ? I understand Step 1 and Step 2 should be done for all the nodes of replicaset to ensure we get OS metrics from those node. Can anyone please clarify reg step 3 and step 4.

Hi Alok,

If your replica set is active than user can be created on the primary node.
All services should be added for monitoring (pmm-admin add mongodb)


Step 3 need to run on primary node only. Rest steps should execute on all nodes separately.

1 Like

Yes, step 4, you need to run on each node of replica set


what is the syntax to add replica nodes for monitoring.

i am able to add cluster and but cannot able to add nodes.

pmm-admin list
Service type Service name Address and port Service ID
MongoDB xxxxxxx xxxxxxxxxxxx

Step1: add cluster → pmm-admin add mongodb --username=pmm --password=xxxx --cluster mongodev0 mongodev

on node1:

Step2: add replica cluster → pmm-admin add mongodb:metrics --uri “mongodb://xxxxxx:27017/admin?replicaSet=mongodev0” mongonode1 --cluster mongodev0 mongodev

Error at step2 : pmm-admin: error: expected command but got “mongodb:metrics”, try --help

Please advise

1 Like

Can you share out put of

pmm-admin list.

it’s pmm-admin add mongodb not mongodb:metrics
if you have replica set, you need to add mongo as a cluster so that you will find all node under one cluster on dashboard.

pmm-admin add mongodb --username=pmm --password=xxxx --cluster clustername

if you have standalone node. Then you need to add mongo node.

pmm-admin add mongodb --username=pmm --password=pmm


Thank you Rohit.

pmm-admin list
Service type Service name Address and port Service ID
MongoDB xxxdb /service_id/xxxxxx

Agent type Status Metrics Mode Agent ID Service ID
pmm_agent Connected /agent_id/xxxx
node_exporter Running push /agent_id/xxx
mongodb_exporter Running push /agent_id/xxxx /service_id/xxxxx
mongodb_profiler_agent Running /agent_id/xxx /service_id/xxxxx
vmagent Running push /agent_id/xxxx

  1. i have a replicaset with three nodes, i am able to see cluster in dash board
  2. but i do not see other node information ( secondary)

pmm-admin add mongodb --username=pmm --password=xxxx --cluster clustername → this is added

how do i configure all nodes/replicaset ( to monitor replication latency etc…)

1 Like

run below on each node

pmm-admin add mongodb --username=pmm --password=xxxx --cluster clustername


Could you check labels set and replication_set on Explore page?
You may use the next command
count by (set, replication_set) (mongodb_mongod_replset_my_state)


1 Like

i have executed below commands on clients to add cluster/nodes

pmm-admin add mongodb --username=pmm --password=xxxx --cluster clustername
pmm-admin add mongodb --username=pmm --password=xxxxx node1
pmm-admin add mongodb --username=pmm --password=xxxxx node2
Secondary2 :
pmm-admin add mongodb --username=pmm --password=xxxx node3

1 Like

i cannot run the same command on all three nodes, only one node is possible , as above command register cluster
error : Service with name “xxxxx” already exists.

1 Like

There is a no reason to add service twice on node1. It’s already monitored after the first command.
Also please use flag –cluster clustername for all nodes.


Thank you Adivinho.

i tried your suggestion , my problem still the same

  1. i do not see replset members ( please refer picture)
    2.just want to know why is the state null

1 Like

Below worked for me


pmm-admin add mongodb --username=pmm --password=xxxxx node1 --cluster clustername


pmm-admin add mongodb --username=pmm --password=xxxxx node2 --cluster clustername

Secondary2 :

pmm-admin add mongodb --username=pmm --password=xxxx node3 --cluster clustername

1 Like