Navigation
This version of the documentation is archived and no longer supported.

replSetGetStatus

Definition

replSetGetStatus

The replSetGetStatus command returns the status of the replica set from the point of view of the server that processed the command. replSetGetStatus must be run against the admin database.

The mongod instance must be a replica set member for replSetGetStatus to return successfully.

Data provided by this command derives from data included in heartbeats sent to the server by other members of the replica set. Because of the frequency of heartbeats, these data can be several seconds out of date.

Tip

In the mongo Shell, this command can also be run through the rs.status helper method.

Helper methods are convenient for mongo users, but they may not return the same level of information as database commands. In cases where the convenience is not needed or the additional return fields are required, use the database command.

Syntax

The command has the following syntax:

db.adminCommand( { replSetGetStatus: 1 } )

Example

The following example runs the replSetGetStatus command on the admin database of the replica set primary:

db.adminCommand( { replSetGetStatus : 1 } )

The command returns the following output for an example replica set primary:

{
   "set" : "replset",
   "date" : ISODate("2019-12-04T04:49:18.693Z"),
   "myState" : 1,
   "term" : NumberLong(3),
   "syncingTo" : "",
   "syncSourceHost" : "",
   "syncSourceId" : -1,
   "heartbeatIntervalMillis" : NumberLong(2000),
   "majorityVoteCount" : 2,
   "writeMajorityCount" : 2,
   "optimes" : {
      "lastCommittedOpTime" : {
         "ts" : Timestamp(1575434954, 1),
         "t" : NumberLong(3)
      },
      "lastCommittedWallTime" : ISODate("2019-12-04T04:49:14.378Z"),
      "readConcernMajorityOpTime" : {
         "ts" : Timestamp(1575434954, 1),
         "t" : NumberLong(3)
      },
      "readConcernMajorityWallTime" : ISODate("2019-12-04T04:49:14.378Z"),
      "appliedOpTime" : {
         "ts" : Timestamp(1575434954, 1),
         "t" : NumberLong(3)
      },
      "durableOpTime" : {
         "ts" : Timestamp(1575434954, 1),
         "t" : NumberLong(3)
      },
      "lastAppliedWallTime" : ISODate("2019-12-04T04:49:14.378Z"),
      "lastDurableWallTime" : ISODate("2019-12-04T04:49:14.378Z")
   },
   "lastStableRecoveryTimestamp" : Timestamp(1575434935, 1),
   "lastStableCheckpointTimestamp" : Timestamp(1575434935, 1),
   "electionCandidateMetrics" : {
      "lastElectionReason" : "stepUpRequestSkipDryRun",
      "lastElectionDate" : ISODate("2019-12-04T04:49:04.085Z"),
      "electionTerm" : NumberLong(3),
      "lastCommittedOpTimeAtElection" : {
         "ts" : Timestamp(1575434935, 1),
         "t" : NumberLong(2)
      },
      "lastSeenOpTimeAtElection" : {
         "ts" : Timestamp(1575434935, 1),
         "t" : NumberLong(2)
      },
      "numVotesNeeded" : 2,
      "priorityAtElection" : 1,
      "electionTimeoutMillis" : NumberLong(10000),
      "priorPrimaryMemberId" : 1,
      "numCatchUpOps" : NumberLong(0),
      "newTermStartDate" : ISODate("2019-12-04T04:49:04.366Z"),
      "wMajorityWriteAvailabilityDate" : ISODate("2019-12-04T04:49:04.382Z")
   },
   "electionParticipantMetrics" : {
      "votedForCandidate" : true,
      "electionTerm" : NumberLong(2),
      "lastVoteDate" : ISODate("2019-12-04T04:16:54.398Z"),
      "electionCandidateMemberId" : 1,
      "voteReason" : "",
      "lastAppliedOpTimeAtElection" : {
         "ts" : Timestamp(1575433013, 1),
         "t" : NumberLong(1)
      },
      "maxAppliedOpTimeInSet" : {
         "ts" : Timestamp(1575433013, 1),
         "t" : NumberLong(1)
      },
      "priorityAtElection" : 1
   },
   "members" : [
      {
         "_id" : 0,
         "name" : "m1.example.net:27017",
         "ip" : "198.51.100.1",
         "health" : 1,
         "state" : 1,
         "stateStr" : "PRIMARY",
         "uptime" : 2019,
         "optime" : {
            "ts" : Timestamp(1575434954, 1),
            "t" : NumberLong(3)
         },
         "optimeDate" : ISODate("2019-12-04T04:49:14Z"),
         "syncingTo" : "",
         "syncSourceHost" : "",
         "syncSourceId" : -1,
         "infoMessage" : "",
         "electionTime" : Timestamp(1575434944, 1),
         "electionDate" : ISODate("2019-12-04T04:49:04Z"),
         "configVersion" : 1,
         "self" : true,
         "lastHeartbeatMessage" : ""
      },
      {
         "_id" : 1,
         "name" : "m2.example.net:27017",
         "ip" : "198.51.100.2",
         "health" : 1,
         "state" : 2,
         "stateStr" : "SECONDARY",
         "uptime" : 2016,
         "optime" : {
            "ts" : Timestamp(1575434954, 1),
            "t" : NumberLong(3)
         },
         "optimeDurable" : {
            "ts" : Timestamp(1575434954, 1),
            "t" : NumberLong(3)
         },
         "optimeDate" : ISODate("2019-12-04T04:49:14Z"),
         "optimeDurableDate" : ISODate("2019-12-04T04:49:14Z"),
         "lastHeartbeat" : ISODate("2019-12-04T04:49:18.138Z"),
         "lastHeartbeatRecv" : ISODate("2019-12-04T04:49:18.460Z"),
         "pingMs" : NumberLong(0),
         "lastHeartbeatMessage" : "",
         "syncingTo" : "m1.example.net:27017",
         "syncSourceHost" : "m1.example.net:27017",
         "syncSourceId" : 0,
         "infoMessage" : "",
         "configVersion" : 1
      },
      {
         "_id" : 2,
         "name" : "m3.example.net:27017",
         "ip" : "198.51.100.3",
         "health" : 1,
         "state" : 2,
         "stateStr" : "SECONDARY",
         "uptime" : 2016,
         "optime" : {
            "ts" : Timestamp(1575434954, 1),
            "t" : NumberLong(3)
         },
         "optimeDurable" : {
            "ts" : Timestamp(1575434954, 1),
            "t" : NumberLong(3)
         },
         "optimeDate" : ISODate("2019-12-04T04:49:14Z"),
         "optimeDurableDate" : ISODate("2019-12-04T04:49:14Z"),
         "lastHeartbeat" : ISODate("2019-12-04T04:49:18.138Z"),
         "lastHeartbeatRecv" : ISODate("2019-12-04T04:49:17.739Z"),
         "pingMs" : NumberLong(0),
         "lastHeartbeatMessage" : "",
         "syncingTo" : "m1.example.net:27017",
         "syncSourceHost" : "m1.example.net:27017",
         "syncSourceId" : 0,
         "infoMessage" : "",
         "configVersion" : 1
      }
   ],
   "ok" : 1,
   "$clusterTime" : {
      "clusterTime" : Timestamp(1575434954, 1),
      "signature" : {
         "hash" : BinData(0,"Dz4WAzT3KpB5XHXwy3MgcjL3M8Q="),
         "keyId" : NumberLong("6766433010175705091")
      }
   },
   "operationTime" : Timestamp(1575434954, 1)
}

The following example runs the replSetGetStatus command on the admin database of the replica set secondary.

db.adminCommand( { replSetGetStatus : 1 } )

The command returns the following output for an example replica set secondary:

{
   "set" : "replset",
   "date" : ISODate("2019-12-04T04:57:46.651Z"),
   "myState" : 2,
   "term" : NumberLong(3),
   "syncingTo" : "m3.example.net:27017",
   "syncSourceHost" : "m3.example.net:27017",
   "syncSourceId" : 2,
   "heartbeatIntervalMillis" : NumberLong(2000),
   "majorityVoteCount" : 2,
   "writeMajorityCount" : 2,
   "optimes" : {
      "lastCommittedOpTime" : {
         "ts" : Timestamp(1575435464, 1),
         "t" : NumberLong(3)
      },
      "lastCommittedWallTime" : ISODate("2019-12-04T04:57:44.571Z"),
      "readConcernMajorityOpTime" : {
         "ts" : Timestamp(1575435464, 1),
         "t" : NumberLong(3)
      },
      "readConcernMajorityWallTime" : ISODate("2019-12-04T04:57:44.571Z"),
      "appliedOpTime" : {
         "ts" : Timestamp(1575435464, 1),
         "t" : NumberLong(3)
      },
      "durableOpTime" : {
         "ts" : Timestamp(1575435464, 1),
         "t" : NumberLong(3)
      },
      "lastAppliedWallTime" : ISODate("2019-12-04T04:57:44.571Z"),
      "lastDurableWallTime" : ISODate("2019-12-04T04:57:44.571Z")
   },
   "lastStableRecoveryTimestamp" : Timestamp(1575435414, 1),
   "lastStableCheckpointTimestamp" : Timestamp(1575435414, 1),
   "electionParticipantMetrics" : {
      "votedForCandidate" : true,
      "electionTerm" : NumberLong(3),
      "lastVoteDate" : ISODate("2019-12-04T04:49:04.109Z"),
      "electionCandidateMemberId" : 0,
      "voteReason" : "",
      "lastAppliedOpTimeAtElection" : {
         "ts" : Timestamp(1575434935, 1),
         "t" : NumberLong(2)
      },
      "maxAppliedOpTimeInSet" : {
         "ts" : Timestamp(1575434935, 1),
         "t" : NumberLong(2)
      },
      "priorityAtElection" : 1,
      "newTermStartDate" : ISODate("2019-12-04T04:49:04.366Z"),
      "newTermAppliedDate" : ISODate("2019-12-04T04:49:06.225Z")
   },
   "members" : [
      {
         "_id" : 0,
         "name" : "m1.example.net:27017",
         "ip" : "198.51.100.1",
         "health" : 1,
         "state" : 1,
         "stateStr" : "PRIMARY",
         "uptime" : 2523,
         "optime" : {
            "ts" : Timestamp(1575435464, 1),
            "t" : NumberLong(3)
         },
         "optimeDurable" : {
            "ts" : Timestamp(1575435464, 1),
            "t" : NumberLong(3)
         },
         "optimeDate" : ISODate("2019-12-04T04:57:44Z"),
         "optimeDurableDate" : ISODate("2019-12-04T04:57:44Z"),
         "lastHeartbeat" : ISODate("2019-12-04T04:57:45.261Z"),
         "lastHeartbeatRecv" : ISODate("2019-12-04T04:57:44.897Z"),
         "pingMs" : NumberLong(0),
         "lastHeartbeatMessage" : "",
         "syncingTo" : "",
         "syncSourceHost" : "",
         "syncSourceId" : -1,
         "infoMessage" : "",
         "electionTime" : Timestamp(1575434944, 1),
         "electionDate" : ISODate("2019-12-04T04:49:04Z"),
         "configVersion" : 1
      },
      {
         "_id" : 1,
         "name" : "m2.example.net:27017",
         "ip" : "198.51.100.2",
         "health" : 1,
         "state" : 2,
         "stateStr" : "SECONDARY",
         "uptime" : 2526,
         "optime" : {
            "ts" : Timestamp(1575435464, 1),
            "t" : NumberLong(3)
         },
         "optimeDate" : ISODate("2019-12-04T04:57:44Z"),
         "syncingTo" : "m3.example.net:27017",
         "syncSourceHost" : "m3.example.net:27017",
         "syncSourceId" : 2,
         "infoMessage" : "",
         "configVersion" : 1,
         "self" : true,
         "lastHeartbeatMessage" : ""
      },
      {
         "_id" : 2,
         "name" : "m3.example.net:27017",
         "ip" : "198.51.100.3",
         "health" : 1,
         "state" : 2,
         "stateStr" : "SECONDARY",
         "uptime" : 2523,
         "optime" : {
            "ts" : Timestamp(1575435464, 1),
            "t" : NumberLong(3)
         },
         "optimeDurable" : {
            "ts" : Timestamp(1575435464, 1),
            "t" : NumberLong(3)
         },
         "optimeDate" : ISODate("2019-12-04T04:57:44Z"),
         "optimeDurableDate" : ISODate("2019-12-04T04:57:44Z"),
         "lastHeartbeat" : ISODate("2019-12-04T04:57:45.261Z"),
         "lastHeartbeatRecv" : ISODate("2019-12-04T04:57:46.556Z"),
         "pingMs" : NumberLong(0),
         "lastHeartbeatMessage" : "",
         "syncingTo" : "m1.example.net:27017",
         "syncSourceHost" : "m1.example.net:27017",
         "syncSourceId" : 0,
         "infoMessage" : "",
         "configVersion" : 1
      }
   ],
   "ok" : 1,
   "$clusterTime" : {
      "clusterTime" : Timestamp(1575435464, 1),
      "signature" : {
         "hash" : BinData(0,"dPsDL+hY+sY6jSvrmrriJdQOeaA="),
         "keyId" : NumberLong("6766433010175705091")
      }
   },
   "operationTime" : Timestamp(1575435464, 1)
}
In earlier versions (3.4.x-4.2.0)

You can include the optional initialSync: 1 to include the replSetGetStatus.initialSyncStatus in the output (you can omit if you do not want to return the initial sync status):

db.adminCommand( { replSetGetStatus : 1, initialSync: 1} )
Starting in MongoDB 4.2.1,

If you run replSetGetStatus on a member during its initial sync, the command returns replSetGetStatus.initialSyncStatus metrics.

db.adminCommand( { replSetGetStatus : 1} )

Once the member finishes its initial sync and transitions to another state,the replSetGetStatus.initialSyncStatus metrics is no longer available.

In earlier versions (3.4.x-4.2.0)

You can include the optional initialSync: 1 to include the replSetGetStatus.initialSyncStatus in the output (you can omit if you do not want to return the initial sync status):

db.adminCommand( { replSetGetStatus : 1, initialSync: 1} )

For 3.4.x-4.2.0 replica sets, replSetGetStatus.initialSyncStatus metrics remains available after the member completes its initial sync. That is, you can run the replSetGetStatus command with the initialSync: 1 on the secondary member to return its initial sync information.

The following example runs the replSetGetStatus command on the admin database of the 4.2.1 replica set member during its initial sync:

{
   "set" : "replset",
   "date" : ISODate("2019-12-04T05:12:52.835Z"),
   "myState" : 5,
   "term" : NumberLong(3),
   "syncingTo" : "m2.example.net:27017",
   "syncSourceHost" : "m2.example.net:27017",
   "syncSourceId" : 1,
   "heartbeatIntervalMillis" : NumberLong(2000),
   "majorityVoteCount" : 2,
   "writeMajorityCount" : 2,
   "optimes" : {
      "lastCommittedOpTime" : {
         "ts" : Timestamp(0, 0),
         "t" : NumberLong(-1)
      },
      "lastCommittedWallTime" : ISODate("1970-01-01T00:00:00Z"),
      "appliedOpTime" : {
         "ts" : Timestamp(0, 0),
         "t" : NumberLong(-1)
      },
      "durableOpTime" : {
         "ts" : Timestamp(0, 0),
         "t" : NumberLong(-1)
      },
      "lastAppliedWallTime" : ISODate("1970-01-01T00:00:00Z"),
      "lastDurableWallTime" : ISODate("1970-01-01T00:00:00Z")
   },
   "lastStableRecoveryTimestamp" : Timestamp(0, 0),
   "lastStableCheckpointTimestamp" : Timestamp(0, 0),
   "initialSyncStatus" : {
      "failedInitialSyncAttempts" : 0,
      "maxFailedInitialSyncAttempts" : 10,
      "initialSyncStart" : ISODate("2019-12-04T05:12:35.719Z"),
      "initialSyncAttempts" : [ ],
      "fetchedMissingDocs" : 0,
      "appliedOps" : 0,
      "initialSyncOplogStart" : Timestamp(1575436355, 1),
      "databases" : {
         "databasesCloned" : 2,
         "admin" : {
            "collections" : 4,
            "clonedCollections" : 4,
            "start" : ISODate("2019-12-04T05:12:35.947Z"),
            "end" : ISODate("2019-12-04T05:12:36.486Z"),
            "elapsedMillis" : 539,
            "admin.system.roles" : {
               "documentsToCopy" : 12,
               "documentsCopied" : 12,
               "indexes" : 2,
               "fetchedBatches" : 1,
               "start" : ISODate("2019-12-04T05:12:35.950Z"),
               "end" : ISODate("2019-12-04T05:12:36.101Z"),
               "elapsedMillis" : 151,
               "receivedBatches" : 1
            },
            "admin.system.users" : {
               "documentsToCopy" : 22,
               "documentsCopied" : 22,
               "indexes" : 2,
               "fetchedBatches" : 1,
               "start" : ISODate("2019-12-04T05:12:36.101Z"),
               "end" : ISODate("2019-12-04T05:12:36.252Z"),
               "elapsedMillis" : 151,
               "receivedBatches" : 1
            },
            "admin.system.keys" : {
               "documentsToCopy" : 2,
               "documentsCopied" : 2,
               "indexes" : 1,
               "fetchedBatches" : 1,
               "start" : ISODate("2019-12-04T05:12:36.252Z"),
               "end" : ISODate("2019-12-04T05:12:36.372Z"),
               "elapsedMillis" : 120,
               "receivedBatches" : 1
            },
            "admin.system.version" : {
               "documentsToCopy" : 2,
               "documentsCopied" : 2,
               "indexes" : 1,
               "fetchedBatches" : 1,
               "start" : ISODate("2019-12-04T05:12:36.372Z"),
               "end" : ISODate("2019-12-04T05:12:36.486Z"),
               "elapsedMillis" : 114,
               "receivedBatches" : 1
            }
         },
         "config" : {
            "collections" : 2,
            "clonedCollections" : 2,
            "start" : ISODate("2019-12-04T05:12:36.486Z"),
            "end" : ISODate("2019-12-04T05:12:36.863Z"),
            "elapsedMillis" : 377,
            "config.transactions" : {
               "documentsToCopy" : 0,
               "documentsCopied" : 0,
               "indexes" : 1,
               "fetchedBatches" : 0,
               "start" : ISODate("2019-12-04T05:12:36.487Z"),
               "end" : ISODate("2019-12-04T05:12:36.645Z"),
               "elapsedMillis" : 158,
               "receivedBatches" : 0
            },
            "config.system.sessions" : {
               "documentsToCopy" : 1,
               "documentsCopied" : 1,
               "indexes" : 2,
               "fetchedBatches" : 1,
               "start" : ISODate("2019-12-04T05:12:36.645Z"),
               "end" : ISODate("2019-12-04T05:12:36.863Z"),
               "elapsedMillis" : 218,
               "receivedBatches" : 1
            }
         },
         "test" : {
            "collections" : 1,
            "clonedCollections" : 0,
            "start" : ISODate("2019-12-04T05:12:36.863Z"),
            "test.hugeindex" : {
               "documentsToCopy" : 25000,
               "documentsCopied" : 9187,
               "indexes" : 2,
               "fetchedBatches" : 8,
               "start" : ISODate("2019-12-04T05:12:36.865Z"),
               "receivedBatches" : 9
            }
         }
      }
   },
   "members" : [
      {
         "_id" : 0,
         "name" : "m1.example.net:27017",
         "ip" : "198.51.100.1",
         "health" : 1,
         "state" : 1,
         "stateStr" : "PRIMARY",
         "uptime" : 17,
         "optime" : {
            "ts" : Timestamp(1575436355, 1),
            "t" : NumberLong(3)
         },
         "optimeDurable" : {
            "ts" : Timestamp(1575436355, 1),
            "t" : NumberLong(3)
         },
         "optimeDate" : ISODate("2019-12-04T05:12:35Z"),
         "optimeDurableDate" : ISODate("2019-12-04T05:12:35Z"),
         "lastHeartbeat" : ISODate("2019-12-04T05:12:52.216Z"),
         "lastHeartbeatRecv" : ISODate("2019-12-04T05:12:51.485Z"),
         "pingMs" : NumberLong(0),
         "lastHeartbeatMessage" : "",
         "syncingTo" : "",
         "syncSourceHost" : "",
         "syncSourceId" : -1,
         "infoMessage" : "",
         "electionTime" : Timestamp(1575434944, 1),
         "electionDate" : ISODate("2019-12-04T04:49:04Z"),
         "configVersion" : 3
      },
      {
         "_id" : 1,
         "name" : "m2.example.net:27017",
         "ip" : "198.51.100.2",
         "health" : 1,
         "state" : 2,
         "stateStr" : "SECONDARY",
         "uptime" : 17,
         "optime" : {
            "ts" : Timestamp(1575436355, 1),
            "t" : NumberLong(3)
         },
         "optimeDurable" : {
            "ts" : Timestamp(1575436355, 1),
            "t" : NumberLong(3)
         },
         "optimeDate" : ISODate("2019-12-04T05:12:35Z"),
         "optimeDurableDate" : ISODate("2019-12-04T05:12:35Z"),
         "lastHeartbeat" : ISODate("2019-12-04T05:12:52.216Z"),
         "lastHeartbeatRecv" : ISODate("2019-12-04T05:12:52.728Z"),
         "pingMs" : NumberLong(0),
         "lastHeartbeatMessage" : "",
         "syncingTo" : "",
         "syncSourceHost" : "",
         "syncSourceId" : -1,
         "infoMessage" : "",
         "configVersion" : 3
      },
      {
         "_id" : 2,
         "name" : "m3.example.net:27017",
         "ip" : "198.51.100.3",
         "health" : 1,
         "state" : 5,
         "stateStr" : "STARTUP2",
         "uptime" : 71,
         "optime" : {
            "ts" : Timestamp(0, 0),
            "t" : NumberLong(-1)
         },
         "optimeDate" : ISODate("1970-01-01T00:00:00Z"),
         "syncingTo" : "m2.example.net:27017",
         "syncSourceHost" : "m2.example.net:27017",
         "syncSourceId" : 1,
         "infoMessage" : "",
         "configVersion" : 3,
         "self" : true,
         "lastHeartbeatMessage" : ""
      }
   ],
   "ok" : 1
}

Output

The replSetGetStatus command returns a document with the following fields:

replSetGetStatus.set

The set value is the name of the replica set, configured in the replSetName setting. This is the same value as _id in rs.conf().

replSetGetStatus.date

An ISODate formatted date and time that reflects the current time according to the server that processed the replSetGetStatus command. Compare this to the values of replSetGetStatus.members[n].lastHeartbeat to find the operational latency between this server and the other members of the replica set.

replSetGetStatus.myState

An integer between 0 and 10 that represents the replica state of the current member.

replSetGetStatus.term

New in version 3.2.

The election count for the replica set, as known to this replica set member. The term is used by the distributed consensus algorithm to ensure correctness.

replSetGetStatus.syncingTo

Deprecated since version 4.0,: 3.6.6, 3.4.16

Starting in MongoDB 4.0 (and 3.6.6, 3.4.16), MongoDB deprecates syncingTo. See replSetGetStatus.syncSourceHost instead.

The syncingTo field holds the hostname of the member from which this instance syncs. If this instance is a primary, returns an empty string "".

replSetGetStatus.syncSourceHost

New in version 4.0,: 3.6.6, 3.4.16

The syncSourceHost field holds the hostname of the member from which this instance syncs.

If this instance is a primary, syncSourceHost is an empty string and the syncSourceId -1.

replSetGetStatus.syncSourceId

New in version 4.0,: 3.6.6, 3.4.16

The syncSourceId field holds the replSetGetStatus.members[n]._id of the member from which this instance syncs.

If this instance is a primary, syncSourceHost is an empty string and the syncSourceId -1.

replSetGetStatus.heartbeatIntervalMillis

New in version 3.2.

The frequency in milliseconds of the heartbeats.

replSetGetStatus.majorityVoteCount

New in version 4.2.1.

The number that corresponds to the majority votes needed to elect a new primary in an election.

replSetGetStatus.writeMajorityCount

New in version 4.2.1.

The number of data-bearing voting members (i.e. not arbiters) needed to fulfill write concern "majority". Writes can only be applied to data-bearing members.

For the calculation of replSetGetStatus.writeMajorityCount, see Calculating Majority for Write Concern.

replSetGetStatus.optimes

New in version 3.4.

The optimes field holds a document that contains optimes used to inspect replication progress. Starting in MongoDB 4.2, the optimes include the corresponding ISODate-formatted date strings for the various optimes.

Each optime value is a document that contains:

  • ts, the Timestamp of the operation.
  • t, the term in which the operation was originally generated on the primary.
replSetGetStatus.optimes.lastCommittedOpTime

Information, from the viewpoint of this member, regarding the most recent operation that has been written to a majority of replica set members.

replSetGetStatus.optimes.lastCommittedWallTime

The ISODate-formatted date string corresponding to lastCommittedOpTime.

The lastCommittedWallTime may not accurately reflect lastCommittedOpTime if all members are not on MongoDB 4.2 or greater since the lastCommittedWallTime requires communication with other members of the deployment.

New in version 4.2.

replSetGetStatus.optimes.readConcernMajorityOpTime

Information, from the viewpoint of this member, regarding the most recent operation that can fulfill read concern "majority" queries; i.e. the most recent lastCommittedOpTime that can fulfill "majority" queries. readConcernMajorityOpTime is either less than or equal to lastCommittedOpTime.

replSetGetStatus.optimes.readConcernMajorityWallTime

The ISODate-formatted date string corresponding to readConcernMajorityOpTime.

The readConcernMajorityWallTime may not accurately reflect readConcernMajorityOpTime if all members are not on MongoDB 4.2 or greater since the readConcernMajorityWallTime requires communication with other members of the deployment.

New in version 4.2.

replSetGetStatus.optimes.appliedOpTime

Information, from the viewpoint of this member, regarding the most recent operation that has been applied to this member of the replica set.

replSetGetStatus.optimes.lastAppliedWallTime

The ISODate-formatted date string corresponding to appliedOpTime.

New in version 4.2.

replSetGetStatus.optimes.durableOpTime

Information, from the viewpoint of this member, regarding the most recent operation that has been written to the journal of this member of the replica set.

replSetGetStatus.optimes.lastDurableWallTime

The ISODate-formatted date string corresponding to durableOpTime.

New in version 4.2.

replSetGetStatus.lastStableCheckpointTimestamp

Deprecated since version 4.2.

Available for the WiredTiger Storage Engine.

Timestamp at which the current, or a previous, persisted checkpoint was taken. Although lastStableCheckpointTimestamp may lag the most recent persisted checkpoint, the returned timestamp is guaranteed to be persisted in a stable checkpoint to disk.

A null value indicates that no stable checkpoint exists.

New in version 4.0.

replSetGetStatus.lastStableRecoveryTimestamp

New in version 4.2.

For internal use only

replSetGetStatus.electionCandidateMetrics

New in version 4.2.1.

Metrics related to the election of the current primary. electionCandidateMetrics is only available on the primary or a candidate for election. For a candidate, the metrics becomes unavailable once the candidate loses the election.

replSetGetStatus.electionCandidateMetrics.lastElectionReason

New in version 4.2.1.

Reason the member called the election.

replSetGetStatus.electionCandidateMetrics.lastElectionDate

New in version 4.2.1.

The date and time the member called the election.

replSetGetStatus.electionCandidateMetrics.electionTerm

Changed in version 4.2.2: In v4.2.1, electionTerm was named electionTerm.

The member’s election count (i.e. term) at the time it called for the new election.

replSetGetStatus.electionCandidateMetrics.lastCommittedOpTimeAtElection

New in version 4.2.1.

The most recent majority-committed optime, as seen by this member, at the time it called for the new election.

replSetGetStatus.electionCandidateMetrics.lastSeenOpTimeAtElection

New in version 4.2.1.

The member’s most recent applied optime at the time it called for the new election.

replSetGetStatus.electionCandidateMetrics.numVotesNeeded

New in version 4.2.1.

The number of votes needed to win the election.

replSetGetStatus.electionCandidateMetrics.priorityAtElection

New in version 4.2.1.

The member’s priority at the time it called the election.

replSetGetStatus.electionCandidateMetrics.electionTimeoutMillis

New in version 4.2.1.

The replica set’s configured electionTimeoutMillis setting at the time of the election.

replSetGetStatus.electionCandidateMetrics.priorPrimaryMemberId

New in version 4.2.1.

The members[n]._id of the previous primary. If there is no previous primary, then the field is not present.

replSetGetStatus.electionCandidateMetrics.targetCatchupOpTime

New in version 4.2.1.

The newly-elected primary’s target opTime for its catchup process. Only when the newly-elected primary reaches the target catchup opTime can it start accepting writes.

replSetGetStatus.electionCandidateMetrics.numCatchUpOps

New in version 4.2.1.

The number of operations applied by the newly-elected primary as it successfully concludes its catchup process.

replSetGetStatus.electionCandidateMetrics.newTermStartDate

New in version 4.2.1.

The date and time at which the member’s term as the primary started (i.e. the date and time at which a new term entry was written to the oplog).

replSetGetStatus.electionCandidateMetrics.wMajorityWriteAvailabilityDate

New in version 4.2.1.

The date and time at which the write concern "majority" became available after the election for the replica set(i.e. the date and time at which the new term oplog entry was majority committed).

replSetGetStatus.electionParticipantMetrics

Metrics related to the latest election in which the member participated.

New in version 4.2.2.

replSetGetStatus.electionParticipantMetrics.votedForCandidate

A boolean which indicates whether the member voted for the candidate calling the election.

New in version 4.2.2.

replSetGetStatus.electionParticipantMetrics.electionTerm

The term of the election in which the member participated. The term identifies the election associated with the participant metrics.

New in version 4.2.2.

replSetGetStatus.electionParticipantMetrics.lastVoteDate

An ISODate formatted date string that reflects when the participant voted.

New in version 4.2.2.

replSetGetStatus.electionParticipantMetrics.electionCandidateMemberId

The members[n]._id of the candidate calling the election.

New in version 4.2.2.

replSetGetStatus.electionParticipantMetrics.voteReason

The reason for the vote if the member did not vote for the candidate. If the member voted for the candidate, the value is an empty string.

New in version 4.2.2.

replSetGetStatus.electionParticipantMetrics.lastAppliedOpTimeAtElection

This member’s latest applied optime at the time of the election.

The optime value is a document that contains the Timestamp (ts) and the term (t).

replSetGetStatus.electionParticipantMetrics.maxAppliedOpTimeInSet

The most recent applied optime for any member of this replica set, as known by this member.

The optime value is a document that contains the Timestamp (ts) and the term (t).

New in version 4.2.2.

replSetGetStatus.electionParticipantMetrics.priorityAtElection

The member’s priority at the time of the election.

New in version 4.2.2.

replSetGetStatus.electionParticipantMetrics.newTermStartDate

The date and time at which the elected primary’s term started; this corresponds to when the primary wrote the new term entry to its oplog and not when the entry was added (i.e. replicated) to the secondary’s oplog.

The field is available for secondary members only. For the primary, see replSetGetStatus.electionCandidateMetrics.newTermStartDate instead.

New in version 4.2.2.

replSetGetStatus.electionParticipantMetrics.newTermAppliedDate

The date and time at which this secondary applied the new term entry.

The field is available for secondary members only.

New in version 4.2.2.

replSetGetStatus.initialSyncStatus

New in version 3.4.

A document provides information on the progress and status of initial sync on this member.

Availability

Starting in MongoDB 4.2.1, replSetGetStatus.initialSyncStatus metrics are only available when run on a member during its initial sync (i.e. STARTUP2 state).

In earlier versions (3.4.x-4.2.0), replSetGetStatus.initialSyncStatus metrics are available when the command is run with initialSync: 1 option on a secondary or a member in its STARTUP2 state, even after the member completes its initial sync. However, some fields that relate to the progress of an on-going initial sync only appear while the initial sync is in progress and do not appear once the initial sync completes.

replSetGetStatus.initialSyncStatus.failedInitialSyncAttempts

New in version 3.4.

The number of times the initial sync failed and had to restart on this member.

Availability

Starting in MongoDB 4.2.1, replSetGetStatus.initialSyncStatus metrics are only available when run on a member during its initial sync (i.e. STARTUP2 state).

In earlier versions (3.4.x-4.2.0), replSetGetStatus.initialSyncStatus metrics are available when the command is run with initialSync: 1 option on a secondary or a member in its STARTUP2 state, even after the member completes its initial sync. However, some fields that relate to the progress of an on-going initial sync only appear while the initial sync is in progress and do not appear once the initial sync completes.

replSetGetStatus.initialSyncStatus.maxFailedInitialSyncAttempts

New in version 3.4.

The maximum number of times the initial sync can restart on this member before the member shuts down.

Availability

Starting in MongoDB 4.2.1, replSetGetStatus.initialSyncStatus metrics are only available when run on a member during its initial sync (i.e. STARTUP2 state).

In earlier versions (3.4.x-4.2.0), replSetGetStatus.initialSyncStatus metrics are available when the command is run with initialSync: 1 option on a secondary or a member in its STARTUP2 state, even after the member completes its initial sync. However, some fields that relate to the progress of an on-going initial sync only appear while the initial sync is in progress and do not appear once the initial sync completes.

replSetGetStatus.initialSyncStatus.initialSyncStart

New in version 3.4.

The start timestamp of the initial sync for this member.

Availability

Starting in MongoDB 4.2.1, replSetGetStatus.initialSyncStatus metrics are only available when run on a member during its initial sync (i.e. STARTUP2 state).

In earlier versions (3.4.x-4.2.0), replSetGetStatus.initialSyncStatus metrics are available when the command is run with initialSync: 1 option on a secondary or a member in its STARTUP2 state, even after the member completes its initial sync. However, some fields that relate to the progress of an on-going initial sync only appear while the initial sync is in progress and do not appear once the initial sync completes.

replSetGetStatus.initialSyncStatus.initialSyncEnd

New in version 3.4.

The end timestamp of the initial sync for this member.

Availability

Starting in MongoDB 4.2.1, replSetGetStatus.initialSyncStatus metrics are only available when run on a member during its initial sync (i.e. STARTUP2 state).

In earlier versions (3.4.x-4.2.0), replSetGetStatus.initialSyncStatus metrics are available when the command is run with initialSync: 1 option on a secondary or a member in its STARTUP2 state, even after the member completes its initial sync. However, some fields that relate to the progress of an on-going initial sync only appear while the initial sync is in progress and do not appear once the initial sync completes.

replSetGetStatus.initialSyncStatus.initialSyncElapsedMillis

New in version 3.4.

The number of milliseconds between initialSyncStart and initialSyncEnd.

Availability

Starting in MongoDB 4.2.1, replSetGetStatus.initialSyncStatus metrics are only available when run on a member during its initial sync (i.e. STARTUP2 state).

In earlier versions (3.4.x-4.2.0), replSetGetStatus.initialSyncStatus metrics are available when the command is run with initialSync: 1 option on a secondary or a member in its STARTUP2 state, even after the member completes its initial sync. However, some fields that relate to the progress of an on-going initial sync only appear while the initial sync is in progress and do not appear once the initial sync completes.

replSetGetStatus.initialSyncStatus.initialSyncAttempts

New in version 3.4.

Array of documents where each document corresponds to a single initial sync attempt. See also failedInitialSyncAttempts.

Each document contains the following information for the initial sync attempt:

{
   "durationMillis" : <duration in milliseconds>,
   "status" : <exit status>,
   "syncSource" : <source node from which this member performs initial sync>
}

Availability

Starting in MongoDB 4.2.1, replSetGetStatus.initialSyncStatus metrics are only available when run on a member during its initial sync (i.e. STARTUP2 state).

In earlier versions (3.4.x-4.2.0), replSetGetStatus.initialSyncStatus metrics are available when the command is run with initialSync: 1 option on a secondary or a member in its STARTUP2 state, even after the member completes its initial sync. However, some fields that relate to the progress of an on-going initial sync only appear while the initial sync is in progress and do not appear once the initial sync completes.

replSetGetStatus.initialSyncStatus.fetchedMissingDocs

New in version 3.4.

The number of missing (i.e. uncloned) documents that were fetched from the sync source in order to apply to those documents the updates that occurred after the initial sync started.

As part of the initial sync process, the member uses the oplog to update its data set to reflect the current state of the replica set.

Availability

Starting in MongoDB 4.2.1, replSetGetStatus.initialSyncStatus metrics are only available when run on a member during its initial sync (i.e. STARTUP2 state).

In earlier versions (3.4.x-4.2.0), replSetGetStatus.initialSyncStatus metrics are available when the command is run with initialSync: 1 option on a secondary or a member in its STARTUP2 state, even after the member completes its initial sync. However, some fields that relate to the progress of an on-going initial sync only appear while the initial sync is in progress and do not appear once the initial sync completes.

replSetGetStatus.initialSyncStatus.appliedOps

New in version 3.4.

The number of ops that occurred after the initial sync started and were applied after cloning the databases.

As part of the initial sync process, the member uses the oplog to update its data set to reflect the current state of the replica set.

Availability

Starting in MongoDB 4.2.1, replSetGetStatus.initialSyncStatus metrics are only available when run on a member during its initial sync (i.e. STARTUP2 state).

In earlier versions (3.4.x-4.2.0), replSetGetStatus.initialSyncStatus metrics are available when the command is run with initialSync: 1 option on a secondary or a member in its STARTUP2 state, even after the member completes its initial sync. However, some fields that relate to the progress of an on-going initial sync only appear while the initial sync is in progress and do not appear once the initial sync completes.

replSetGetStatus.initialSyncStatus.initialSyncOplogStart

New in version 3.4.

The start timestamp of the oplog application stage of the initial sync where the member applies changes that occurred after the initial sync start.

As part of the initial sync process, the member uses the oplog to update its data set to reflect the current state of the replica set.

Availability

Starting in MongoDB 4.2.1, replSetGetStatus.initialSyncStatus metrics are only available when run on a member during its initial sync (i.e. STARTUP2 state).

In earlier versions (3.4.x-4.2.0), replSetGetStatus.initialSyncStatus metrics are available when the command is run with initialSync: 1 option on a secondary or a member in its STARTUP2 state, even after the member completes its initial sync. However, some fields that relate to the progress of an on-going initial sync only appear while the initial sync is in progress and do not appear once the initial sync completes.

replSetGetStatus.initialSyncStatus.initialSyncOplogEnd

New in version 3.4.

The end timestamp of the oplog application stage of the initial sync where the member applies changes that occurred after the initial sync start.

As part of the initial sync process, the member uses the oplog to update its data set to reflect the current state of the replica set.

Availability

Starting in MongoDB 4.2.1, replSetGetStatus.initialSyncStatus metrics are only available when run on a member during its initial sync (i.e. STARTUP2 state).

In earlier versions (3.4.x-4.2.0), replSetGetStatus.initialSyncStatus metrics are available when the command is run with initialSync: 1 option on a secondary or a member in its STARTUP2 state, even after the member completes its initial sync. However, some fields that relate to the progress of an on-going initial sync only appear while the initial sync is in progress and do not appear once the initial sync completes.

replSetGetStatus.initialSyncStatus.databases

New in version 3.4.

Detail on the databases cloned during initial sync.

Availability

Starting in MongoDB 4.2.1, replSetGetStatus.initialSyncStatus metrics are only available when run on a member during its initial sync (i.e. STARTUP2 state).

In earlier versions (3.4.x-4.2.0), replSetGetStatus.initialSyncStatus metrics are available when the command is run with initialSync: 1 option on a secondary or a member in its STARTUP2 state, even after the member completes its initial sync. However, some fields that relate to the progress of an on-going initial sync only appear while the initial sync is in progress and do not appear once the initial sync completes.

replSetGetStatus.initialSyncStatus.databases.databasesCloned

New in version 3.4.

Number of databases cloned during initial sync.

Availability

Starting in MongoDB 4.2.1, replSetGetStatus.initialSyncStatus metrics are only available when run on a member during its initial sync (i.e. STARTUP2 state).

In earlier versions (3.4.x-4.2.0), replSetGetStatus.initialSyncStatus metrics are available when the command is run with initialSync: 1 option on a secondary or a member in its STARTUP2 state, even after the member completes its initial sync. However, some fields that relate to the progress of an on-going initial sync only appear while the initial sync is in progress and do not appear once the initial sync completes.

replSetGetStatus.initialSyncStatus.databases.<dbname>

New in version 3.4.

For each database, a document that returns information regarding the progress of the cloning of that database.

{
   "collections" : <number of collections to clone in the database>,
   "clonedCollections" : <number of collections cloned to date>,
   "start" : <start date and time for the database clone>,
   "end" : <end date and time for the database clone>,
   "elapsedMillis" : <duration of the database clone>,
   "<db>.<collection>" : {
      "documentsToCopy" : <number of documents to copy>,
      "documentsCopied" : <number of documents copied to date>,
      "indexes" :  <number of indexes>,
      "fetchedBatches" :  <number of batches of documents fetched to date>,
      "start" :  <start date and time for the collection clone>,
      "end" : <end date and time for the collection clone>,
      "elapsedMillis" : <duration of the collection clone>,
      "receivedBatches" : <number of batches of documents received to date>  // Added in 4.2
   }
}

Availability

Starting in MongoDB 4.2.1, replSetGetStatus.initialSyncStatus metrics are only available when run on a member during its initial sync (i.e. STARTUP2 state).

In earlier versions (3.4.x-4.2.0), replSetGetStatus.initialSyncStatus metrics are available when the command is run with initialSync: 1 option on a secondary or a member in its STARTUP2 state, even after the member completes its initial sync. However, some fields that relate to the progress of an on-going initial sync only appear while the initial sync is in progress and do not appear once the initial sync completes.

replSetGetStatus.members

The members field holds an array that contains a document for every member in the replica set.

replSetGetStatus.members[n]._id

The identifier for the member.

replSetGetStatus.members[n].name

The name of the member.

replSetGetStatus.members[n].ip

Available in 4.2.0-4.2.2; Removed starting in 4.2.3

The resolved IP address of the member. If the mongod is unable to resolve the replSetGetStatus.members[n].name to an IP address, the return value is a BSON null. Otherwise, the returned value is a string representation of the resolved IP address.

replSetGetStatus.members[n].self

A boolean that indicates if the member is the current mongod instance.

The self field is only included in the document for the current mongod instance, and as such, its value is always true.

replSetGetStatus.members[n].health

A number that indicates if the member is up (i.e. 1) or down (i.e. 0).

replSetGetStatus.members[n].state

An integer between 0 and 10 that represents the replica state of the member.

replSetGetStatus.members[n].stateStr

A string that describes state.

replSetGetStatus.members[n].uptime

For the member on which the replSetGetStatus command is run, uptime is the the number of seconds the member has been online.

For the other members, uptime is the number of seconds the member has been in continuous communication with the member on which the replSetGetStatus command was run.

replSetGetStatus.members[n].optime

Information regarding the last operation from the operation log that this member has applied.

Changed in version 3.2.

optime returns a document that contains:

  • ts, the Timestamp of the last operation applied to this member of the replica set from the oplog.
  • t, the term in which the last applied operation was originally generated on the primary.
replSetGetStatus.members[n].optimeDurable

New in version 3.4.

Information regarding the last operation from the operation log that this member has applied to its journal.

optimeDurable returns a document that contains:

  • ts, the Timestamp of the operation.
  • t, the term in which this operation was originally generated on the primary.
replSetGetStatus.members[n].optimeDate

An ISODate formatted date string that reflects the last entry from the oplog that this member applied. If this differs significantly from lastHeartbeat this member is either experiencing “replication lag” or there have not been any new operations since the last update. Compare members.optimeDate between all of the members of the set.

replSetGetStatus.members[n].optimeDurableDate

New in version 3.4.

An ISODate formatted date string that reflects the last entry from the oplog that this member applied to its journal.

replSetGetStatus.members[n].electionTime

For the current primary, information regarding the election Timestamp from the operation log. See Replica Set High Availability for more information about elections.

replSetGetStatus.members[n].electionDate

For the current primary, an ISODate formatted date string that reflects the election date. See Replica Set High Availability for more information about elections.

replSetGetStatus.members[n].self

Indicates which replica set member processed the replSetGetStatus command.

replSetGetStatus.members[n].lastHeartbeat

An ISODate formatted date and time that reflects the last time the server that processed the replSetGetStatus command received a response from a heartbeat that it sent to this member (members[n]). Compare this value to the values of the date and lastHeartBeatRecv fields to track latency between these replica set members.

This value is only available for replica set members other than the server specified by replSetGetStatus.members[n].self.

replSetGetStatus.members[n].lastHeartbeatRecv

An ISODate formatted date and time that reflects the last time the server that processed the replSetGetStatus command received a heartbeat request from this member (members[n]). Compare this value to the values of the date and lastHeartBeat fields to track latency between these replica set members.

This value is only available for replica set members other than the server specified by replSetGetStatus.members[n].self.

replSetGetStatus.members[n].lastHeartbeatMessage

When the last heartbeat included an extra message, the lastHeartbeatMessage contains a string representation of that message.

replSetGetStatus.members[n].pingMs

The pingMs represents the number of milliseconds (ms) that a round-trip packet takes to travel between the remote member and the local instance.

This value does not appear for the member that returns the rs.status() data.

replSetGetStatus.members[n].syncingTo

Deprecated since version 4.0,: 3.6.6, 3.4.16

Starting in MongoDB 4.0 (and 3.6.6, 3.4.16), MongoDB deprecates syncingTo. See replSetGetStatus.members[n].syncSourceHost instead.

The syncingTo field holds the hostname of the member from which this instance is syncing. If the member is a primary, returns an empty string "".

replSetGetStatus.members[n].syncSourceHost

New in version 4.0,: 3.6.6, 3.4.16

The syncSourceHost field holds the hostname of the member from which this instance syncs.

If the replSetGetStatus.members[n] is a primary, syncSourceHost is an empty string and the syncSourceId -1.

replSetGetStatus.members[n].syncSourceId

New in version 4.0,: 3.6.6, 3.4.16

The syncSourceId field holds the replSetGetStatus.members[n]._id value of the syncSourceHost.

If the replSetGetStatus.members[n] is a primary, syncSourceHost is an empty string and the syncSourceId -1.

replSetGetStatus.members[n].configVersion

The configVersion value is the replica set configuration version.

See also Response for details on the ok status field, the operationTime field and the $clusterTime field.