To monitor the overall replication status, use the rs.status() shell method. This shell method is actually a wrapper for the replSetGetStatus database command. Here is a summary of the information keys to monitor:
Key | What to look for |
optimes | There should not be a large difference between the values for lastCommittedOpTime and appliedOpTime. |
electionCandidateMetrics | Introduced in MongoDB 4.2.1, this metric is only available when connecting to the primary. The difference between lastElectionDate and newTermStartDate should be a few milliseconds. If not, the election process is being drawn out. Consider adding an arbiter to the replica set. |
members | Information presented under this key is further subdivided by a replica set member. For each given member, things to monitor include the following: state should be 1 (primary), 2 (secondary), or 7 (arbiter). A value... |