replSetGetStatus
Definition
replSetGetStatus
- The
replSetGetStatus
command returns the status of the replicaset 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 forreplSetGetStatus
to return successfully.
Data provided by this command derives from data included inheartbeats sent to the server by other members of the replica set.Because of the frequency of heartbeats, these data can be severalseconds out of date.
Syntax
The command has the following syntax:
- db.adminCommand( { replSetGetStatus: 1 } )
- Starting in MongoDB 4.2.1
- If you run
replSetGetStatus
or themongo
shell helperrs.status()
on amember during its initial sync(i.e.STARTUP2
state), the command returnsreplSetGetStatus.initialSyncStatus
metrics.
Once the member finishes its initial sync and transitions toanother state, the replSetGetStatus.initialSyncStatus
metrics are no longer available.
- In earlier versions (3.4.x-4.2.0)
- To return initial sync statusinformation, include
initialSync: 1
in the command on asecondary member or a member inSTARTUP2
state:
- db.adminCommand( { replSetGetStatus: 1, initialSync: 1 } )
The replSetGetStatus.initialSyncStatus
metrics remainsavailable after the member completes its initial sync. That is,you can run the replSetGetStatus
command with theinitialSync: 1
on the secondary member to return its initialsync information.
You cannot specify initialSync: 1
in the mongo
shell helper rs.status()
.
Example
- Primary
- Secondary
- Include Initial Sync Metrics
The following example runs the replSetGetStatus
command on the admin database of the replica setprimary:
- db.adminCommand( { replSetGetStatus : 1 } )
The command returns the following output for an examplereplica set primary:
- {
- "set" : "replset",
- "date" : ISODate("2019-10-14T15:09:28.182Z"),
- "myState" : 1,
- "term" : NumberLong(1),
- "syncingTo" : "",
- "syncSourceHost" : "",
- "syncSourceId" : -1,
- "heartbeatIntervalMillis" : NumberLong(2000),
- "majorityVoteCount" : 2, // Available starting in 4.2.1
- "writeMajorityCount" : 2, // Available starting in 4.2.1
- "optimes" : {
- "lastCommittedOpTime" : {
- "ts" : Timestamp(1571065766, 1),
- "t" : NumberLong(1)
- },
- "lastCommittedWallTime" : ISODate("2019-10-14T15:09:26.120Z"),
- "readConcernMajorityOpTime" : {
- "ts" : Timestamp(1571065766, 1),
- "t" : NumberLong(1)
- },
- "readConcernMajorityWallTime" : ISODate("2019-10-14T15:09:26.120Z"),
- "appliedOpTime" : {
- "ts" : Timestamp(1571065766, 1),
- "t" : NumberLong(1)
- },
- "durableOpTime" : {
- "ts" : Timestamp(1571065766, 1),
- "t" : NumberLong(1)
- },
- "lastAppliedWallTime" : ISODate("2019-10-14T15:09:26.120Z"),
- "lastDurableWallTime" : ISODate("2019-10-14T15:09:26.120Z")
- },
- "lastStableRecoveryTimestamp" : Timestamp(1571065746, 2),
- "lastStableCheckpointTimestamp" : Timestamp(1571065746, 2),
- "electionCandidateMetrics" : {
- "lastElectionReason" : "electionTimeout",
- "lastElectionDate" : ISODate("2019-10-14T15:09:05.328Z"),
- "termAtElection" : NumberLong(1),
- "lastCommittedOpTimeAtElection" : {
- "ts" : Timestamp(0, 0),
- "t" : NumberLong(-1)
- },
- "lastSeenOpTimeAtElection" : {
- "ts" : Timestamp(1571065734, 1),
- "t" : NumberLong(-1)
- },
- "numVotesNeeded" : 2,
- "priorityAtElection" : 1,
- "electionTimeoutMillis" : NumberLong(10000),
- "numCatchUpOps" : NumberLong(0),
- "newTermStartDate" : ISODate("2019-10-14T15:09:06.115Z"),
- "wMajorityWriteAvailabilityDate" : ISODate("2019-10-14T15:09:07.333Z")
- },
- "members" : [
- {
- "_id" : 0,
- "name" : "m1.example.net:27017",
- "ip" : "198.51.100.1",
- "health" : 1,
- "state" : 1,
- "stateStr" : "PRIMARY",
- "uptime" : 417,
- "optime" : {
- "ts" : Timestamp(1571066144, 1),
- "t" : NumberLong(1)
- },
- "optimeDate" : ISODate("2019-10-14T15:15:44Z"),
- "syncingTo" : "",
- "syncSourceHost" : "",
- "syncSourceId" : -1,
- "infoMessage" : "",
- "electionTime" : Timestamp(1571065745, 1),
- "electionDate" : ISODate("2019-10-14T15:09:05Z"),
- "configVersion" : 1,
- "self" : true,
- "lastHeartbeatMessage" : ""
- },
- {
- "_id" : 1,
- "name" : "m2.example.net:27017",
- "ip" : "198.51.100.2",
- "health" : 1,
- "state" : 2,
- "stateStr" : "SECONDARY",
- "uptime" : 414,
- "optime" : {
- "ts" : Timestamp(1571066144, 1),
- "t" : NumberLong(1)
- },
- "optimeDurable" : {
- "ts" : Timestamp(1571066144, 1),
- "t" : NumberLong(1)
- },
- "optimeDate" : ISODate("2019-10-14T15:15:44Z"),
- "optimeDurableDate" : ISODate("2019-10-14T15:15:44Z"),
- "lastHeartbeat" : ISODate("2019-10-14T15:15:47.723Z"),
- "lastHeartbeatRecv" : ISODate("2019-10-14T15:15:47.586Z"),
- "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" : 414,
- "optime" : {
- "ts" : Timestamp(1571066144, 1),
- "t" : NumberLong(1)
- },
- "optimeDurable" : {
- "ts" : Timestamp(1571066144, 1),
- "t" : NumberLong(1)
- },
- "optimeDate" : ISODate("2019-10-14T15:15:44Z"),
- "optimeDurableDate" : ISODate("2019-10-14T15:15:44Z"),
- "lastHeartbeat" : ISODate("2019-10-14T15:15:47.723Z"),
- "lastHeartbeatRecv" : ISODate("2019-10-14T15:15:47.612"),
- "pingMs" : NumberLong(0),
- "lastHeartbeatMessage" : "",
- "syncingTo" : "m1.example.net:27017",
- "syncSourceHost" : "m1.example.net:27017",
- "syncSourceId" : 0,
- "infoMessage" : "",
- "configVersion" : 1
- }
- ],
- "ok" : 1,
- "$clusterTime" : {
- "clusterTime" : Timestamp(1571066144, 1),
- "signature" : {
- "hash" : BinData(0,"7KPhkSeNOAlrA081F16Xl30ljOU="),
- "keyId" : NumberLong("6747675998935842818")
- }
- },
- "operationTime" : Timestamp(1571066144, 1)
- }
The following example runs the replSetGetStatus
command on the admin database of the replica setsecondary.
- db.adminCommand( { replSetGetStatus : 1 } )
The command returns the following output for an example replica set secondary:
- {
- "set" : "replset",
- "date" : ISODate("2019-10-15T04:28:13.318Z"),
- "myState" : 2,
- "term" : NumberLong(1),
- "syncingTo" : "m2.example.net:27017",
- "syncSourceHost" : "m2.example.net:27017",
- "syncSourceId" : 1,
- "heartbeatIntervalMillis" : NumberLong(2000),
- "majorityVoteCount" : 2, // Available starting in 4.2.1
- "writeMajorityCount" : 2, // Available starting in 4.2.1
- "optimes" : {
- "lastCommittedOpTime" : {
- "ts" : Timestamp(1571113692, 1),
- "t" : NumberLong(1)
- },
- "lastCommittedWallTime" : ISODate("2019-10-15T04:28:12.660Z"),
- "readConcernMajorityOpTime" : {
- "ts" : Timestamp(1571113692, 1),
- "t" : NumberLong(1)
- },
- "readConcernMajorityWallTime" : ISODate("2019-10-15T04:28:12.660Z"),
- "appliedOpTime" : {
- "ts" : Timestamp(1571113692, 1),
- "t" : NumberLong(1)
- },
- "durableOpTime" : {
- "ts" : Timestamp(1571113692, 1),
- "t" : NumberLong(1)
- },
- "lastAppliedWallTime" : ISODate("2019-10-15T04:28:12.660Z"),
- "lastDurableWallTime" : ISODate("2019-10-15T04:28:12.660Z")
- },
- "lastStableRecoveryTimestamp" : Timestamp(1571113662, 1),
- "lastStableCheckpointTimestamp" : Timestamp(1571113662, 1),
- "members" : [
- {
- "_id" : 0,
- "name" : "m1.example.net:27017",
- "ip" : "198.51.100.1",
- "health" : 1,
- "state" : 1,
- "stateStr" : "PRIMARY",
- "uptime" : 178,
- "optime" : {
- "ts" : Timestamp(1571113682, 1),
- "t" : NumberLong(1)
- },
- "optimeDurable" : {
- "ts" : Timestamp(1571113682, 1),
- "t" : NumberLong(1)
- },
- "optimeDate" : ISODate("2019-10-15T04:28:02Z"),
- "optimeDurableDate" : ISODate("2019-10-15T04:28:02Z"),
- "lastHeartbeat" : ISODate("2019-10-15T04:28:11.857Z"),
- "lastHeartbeatRecv" : ISODate("2019-10-15T04:28:13.043Z"),
- "pingMs" : NumberLong(0),
- "lastHeartbeatMessage" : "",
- "syncingTo" : "",
- "syncSourceHost" : "",
- "syncSourceId" : -1,
- "infoMessage" : "",
- "electionTime" : Timestamp(1571113240, 1),
- "electionDate" : ISODate("2019-10-15T04:20:40Z"),
- "configVersion" : 2
- },
- {
- "_id" : 1,
- "name" : "m2.example.net:27017",
- "ip" : "198.51.100.2",
- "health" : 1,
- "state" : 2,
- "stateStr" : "SECONDARY",
- "uptime" : 178,
- "optime" : {
- "ts" : Timestamp(1571113682, 1),
- "t" : NumberLong(1)
- },
- "optimeDurable" : {
- "ts" : Timestamp(1571113682, 1),
- "t" : NumberLong(1)
- },
- "optimeDate" : ISODate("2019-10-15T04:28:02Z"),
- "optimeDurableDate" : ISODate("2019-10-15T04:28:02Z"),
- "lastHeartbeat" : ISODate("2019-10-15T04:28:11.857Z"),
- "lastHeartbeatRecv" : ISODate("2019-10-15T04:28:13.310Z"),
- "pingMs" : NumberLong(0),
- "lastHeartbeatMessage" : "",
- "syncingTo" : "m1.example.net:27017",
- "syncSourceHost" : "m1.example.net:27017",
- "syncSourceId" : 0,
- "infoMessage" : "",
- "configVersion" : 2
- },
- {
- "_id" : 2,
- "name" : "m3.example.net:27017",
- "ip" : "198.51.100.3",
- "health" : 1,
- "state" : 2,
- "stateStr" : "SECONDARY",
- "uptime" : 465,
- "optime" : {
- "ts" : Timestamp(1571113692, 1),
- "t" : NumberLong(1)
- },
- "optimeDate" : ISODate("2019-10-15T04:28:12Z"),
- "syncingTo" : "m2.example.net:27017",
- "syncSourceHost" : "m2.example.net:27017",
- "syncSourceId" : 1,
- "infoMessage" : "",
- "configVersion" : 2,
- "self" : true,
- "lastHeartbeatMessage" : ""
- }
- ],
- "ok" : 1,
- "$clusterTime" : {
- "clusterTime" : Timestamp(1571113692, 1),
- "signature" : {
- "hash" : BinData(0,"YBSGbOPTeazPhppu6WnyVRZwYms="),
- "keyId" : NumberLong("6747879992702533634")
- }
- },
- "operationTime" : Timestamp(1571113692, 1)
- }
- In earlier versions (3.4.x-4.2.0)
- You can include the optional
initialSync: 1
to includethereplSetGetStatus.initialSyncStatus
in theoutput (you can omit if you do not want to return theinitial sync status):
- db.adminCommand( { replSetGetStatus : 1, initialSync: 1} )
- Starting in MongoDB 4.2.1,
- If you run
replSetGetStatus
on a memberduring its initial sync, the command returnsreplSetGetStatus.initialSyncStatus
metrics.
- db.adminCommand( { replSetGetStatus : 1} )
Once the member finishes its initial sync and transitions toanother 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 includethereplSetGetStatus.initialSyncStatus
in theoutput (you can omit if you do not want to return theinitial sync status):
- db.adminCommand( { replSetGetStatus : 1, initialSync: 1} )
For 3.4.x-4.2.0 replica sets,replSetGetStatus.initialSyncStatus
metrics remainsavailable after the member completes its initial sync.That is, you can run the replSetGetStatus
command with the initialSync: 1
on the secondarymember to return its initial sync information.
The following example runs the replSetGetStatus
command on the admin database of the 4.2.1 replicaset member during its initial sync:
- {
- "set" : "replset",
- "date" : ISODate("2019-10-15T01:26:38.743Z"),
- "myState" : 5,
- "term" : NumberLong(1),
- "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-10-15T01:25:40.989Z"),
- "initialSyncAttempts" : [ ],
- "fetchedMissingDocs" : 0,
- "appliedOps" : 0,
- "initialSyncOplogStart" : Timestamp(1571102740, 1),
- "databases" : {
- "databasesCloned" : 2,
- "admin" : {
- "collections" : 4,
- "clonedCollections" : 4,
- "start" : ISODate("2019-10-15T01:25:41.154Z"),
- "end" : ISODate("2019-10-15T01:25:41.848Z"),
- "elapsedMillis" : 694,
- "admin.system.keys" : {
- "documentsToCopy" : 2,
- "documentsCopied" : 2,
- "indexes" : 1,
- "fetchedBatches" : 1,
- "start" : ISODate("2019-10-15T01:25:41.156Z"),
- "end" : ISODate("2019-10-15T01:25:41.275Z"),
- "elapsedMillis" : 119,
- "receivedBatches" : 1
- },
- "admin.system.version" : {
- "documentsToCopy" : 2,
- "documentsCopied" : 2,
- "indexes" : 1,
- "fetchedBatches" : 1,
- "start" : ISODate("2019-10-15T01:25:41.275Z"),
- "end" : ISODate("2019-10-15T01:25:41.382Z"),
- "elapsedMillis" : 107,
- "receivedBatches" : 1
- },
- "admin.system.users" : {
- "documentsToCopy" : 22,
- "documentsCopied" : 22,
- "indexes" : 2,
- "fetchedBatches" : 1,
- "start" : ISODate("2019-10-15T01:25:41.382Z"),
- "end" : ISODate("2019-10-15T01:25:41.609Z"),
- "elapsedMillis" : 227,
- "receivedBatches" : 1
- },
- "admin.system.roles" : {
- "documentsToCopy" : 12,
- "documentsCopied" : 12,
- "indexes" : 2,
- "fetchedBatches" : 1,
- "start" : ISODate("2019-10-15T01:25:41.609Z"),
- "end" : ISODate("2019-10-15T01:25:41.848Z"),
- "elapsedMillis" : 239,
- "receivedBatches" : 1
- }
- },
- "config" : {
- "collections" : 2,
- "clonedCollections" : 2,
- "start" : ISODate("2019-10-15T01:25:41.848Z"),
- "end" : ISODate("2019-10-15T01:25:42.243Z"),
- "elapsedMillis" : 395,
- "config.transactions" : {
- "documentsToCopy" : 0,
- "documentsCopied" : 0,
- "indexes" : 1,
- "fetchedBatches" : 0,
- "start" : ISODate("2019-10-15T01:25:41.849Z"),
- "end" : ISODate("2019-10-15T01:25:42.010Z"),
- "elapsedMillis" : 161,
- "receivedBatches" : 0
- },
- "config.system.sessions" : {
- "documentsToCopy" : 1,
- "documentsCopied" : 1,
- "indexes" : 2,
- "fetchedBatches" : 1,
- "start" : ISODate("2019-10-15T01:25:42.009Z"),
- "end" : ISODate("2019-10-15T01:25:42.243Z"),
- "elapsedMillis" : 234,
- "receivedBatches" : 1
- }
- },
- "test" : {
- "collections" : 1,
- "clonedCollections" : 0,
- "start" : ISODate("2019-10-15T01:25:42.243Z"),
- "test.hugeindex" : {
- "documentsToCopy" : 25000,
- "documentsCopied" : 22167,
- "indexes" : 2,
- "fetchedBatches" : 18,
- "start" : ISODate("2019-10-15T01:25:42.244Z"),
- "receivedBatches" : 19
- }
- }
- }
- },
- "lastStableRecoveryTimestamp" : Timestamp(1571066406, 1),
- "lastStableCheckpointTimestamp" : Timestamp(1571066406, 1),
- "members" : [
- {
- "_id" : 0,
- "name" : "m1.example.net:27017",
- "ip" : "198.51.100.1",
- "health" : 1,
- "state" : 1,
- "stateStr" : "PRIMARY",
- "uptime" : 57,
- "optime" : {
- "ts" : Timestamp(1571102795, 1),
- "t" : NumberLong(1)
- },
- "optimeDurable" : {
- "ts" : Timestamp(1571102795, 1),
- "t" : NumberLong(1)
- },
- "optimeDate" : ISODate("2019-10-15T01:26:35Z"),
- "optimeDurableDate" : ISODate("2019-10-15T01:26:35Z"),
- "lastHeartbeat" : ISODate("2019-10-15T01:26:37.531Z"),
- "lastHeartbeatRecv" : ISODate("2019-10-15T01:26:38.697Z"),
- "pingMs" : NumberLong(0),
- "lastHeartbeatMessage" : "",
- "syncingTo" : "",
- "syncSourceHost" : "",
- "syncSourceId" : -1,
- "infoMessage" : "",
- "electionTime" : Timestamp(1571101495, 1),
- "electionDate" : ISODate("2019-10-15T01:04:55Z"),
- "configVersion" : 2
- },
- {
- "_id" : 1,
- "name" : "m2.example.net:27017",
- "ip" : "198.51.100.2",
- "health" : 1,
- "state" : 2,
- "stateStr" : "SECONDARY",
- "uptime" : 57,
- "optime" : {
- "ts" : Timestamp(1571102795, 1),
- "t" : NumberLong(1)
- },
- "optimeDurable" : {
- "ts" : Timestamp(1571102795, 1),
- "t" : NumberLong(1)
- },
- "optimeDate" : ISODate("2019-10-15T01:26:35Z"),
- "optimeDurableDate" : ISODate("2019-10-15T01:26:35Z"),
- "lastHeartbeat" : ISODate("2019-10-15T01:26:37.531Z"),
- "lastHeartbeatRecv" : ISODate("2019-10-15T01:26:36.981Z"),
- "pingMs" : NumberLong(0),
- "lastHeartbeatMessage" : "",
- "syncingTo" : "m1.example.net:27017",
- "syncSourceHost" : "m1.example.net:27017",
- "syncSourceId" : 0,
- "infoMessage" : "",
- "configVersion" : 2
- },
- {
- "_id" : 2,
- "name" : "m3.example.net:27017",
- "ip" : "198.51.100.3",
- "health" : 1,
- "state" : 5,
- "stateStr" : "STARTUP2",
- "uptime" : 1316,
- "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" : 2,
- "self" : true,
- "lastHeartbeatMessage" : ""
- }
- ],
- "ok" : 1
- }
Output
The replSetGetStatus command returns a document with thefollowing fields:
replSetGetStatus.
set
- The
set
value is the name of the replica set, configured in thereplSetName
setting. This is the same value as_id
inrs.conf()
.
replSetGetStatus.
date
- An ISODate formatted date and time that reflects the currenttime according to the server that processed thereplSetGetStatus command. Compare this to the values of
replSetGetStatus.members[n].lastHeartbeat
to find theoperational latency between this server and the other members of thereplica set.
replSetGetStatus.
myState
- An integer between
0
and10
that represents the replicastate of the current member.
New in version 3.2.
The election count for the replica set, as known to this replica setmember. The term
is used by thedistributed consensus algorithm to ensure correctness.
Deprecated since version 4.0,: 3.6.6, 3.4.16
Starting in MongoDB 4.0 (and 3.6.6, 3.4.16), MongoDB deprecatessyncingTo
. SeereplSetGetStatus.syncSourceHost
instead.
The syncingTo
field holds the hostname of the member fromwhich this instance syncs. If this instance is a primary, returnsan empty string ""
.
New in version 4.0,: 3.6.6, 3.4.16
The syncSourceHost
field holds thehostname of the member from which this instance syncs.
If this instance is a primary,syncSourceHost
is an empty string andthe syncSourceId
-1
.
New in version 4.0,: 3.6.6, 3.4.16
The syncSourceId
field holds thereplSetGetStatus.members[n]._id
of the member from whichthis instance syncs.
If this instance is a primary,syncSourceHost
is an empty string andthe syncSourceId
-1
.
New in version 3.2.
The frequency in milliseconds of the heartbeats.
New in version 4.2.1.
The number that corresponds to the majority votes needed to elect anew primary in an election.
New in version 4.2.1.
The number of data-bearing voting members (i.e. not arbiters) neededto fulfill write concern "majority"
. Writes can onlybe applied to data-bearing members.
New in version 3.4.
The optimes
field holds a document that contains optimes used to inspect replication progress. Starting in MongoDB4.2, the optimes
include the corresponding ISODate-formatteddate strings for the various optimes.
Each optime value is a document that contains:
ts
, the Timestamp ofthe operation.t
, theterm
in which theoperation was originally generated on the primary.replSetGetStatus.optimes.
lastCommittedOpTime
Information, from the viewpoint of this member, regarding themost recent operation that has been written to a majority ofreplica set members.
- The ISODate-formatted date string corresponding to
lastCommittedOpTime
.
The lastCommittedWallTime
maynot accurately reflectlastCommittedOpTime
if allmembers are not on MongoDB 4.2 or greater since thelastCommittedWallTime
requires communication with other members of the deployment.
New in version 4.2.
replSetGetStatus.optimes.
readConcernMajorityOpTime
Information, from the viewpoint of this member, regarding themost recent operation that can fulfill read concern
"majority"
queries; i.e. the most recentlastCommittedOpTime
that canfulfill"majority"
queries.readConcernMajorityOpTime
iseither less than or equal tolastCommittedOpTime
.- The ISODate-formatted date string corresponding to
readConcernMajorityOpTime
.
The readConcernMajorityWallTime
may not accurately reflectreadConcernMajorityOpTime
ifall members are not on MongoDB 4.2 or greater since thereadConcernMajorityWallTime
requires communication with other members of the deployment.
New in version 4.2.
replSetGetStatus.optimes.
appliedOpTime
Information, from the viewpoint of this member, regarding themost recent operation that has been applied to this member of thereplica set.
- The ISODate-formatted date string corresponding to
appliedOpTime
.
New in version 4.2.
replSetGetStatus.optimes.
durableOpTime
Information, from the viewpoint of this member, regarding themost recent operation that has been written to the journal ofthis member of the replica set.
- The ISODate-formatted date string corresponding to
durableOpTime
.
New in version 4.2.
Deprecated since version 4.2.
Available for the WiredTiger Storage Engine.
Timestamp at which the current, or a previous, persisted checkpointwas taken. AlthoughlastStableCheckpointTimestamp
may lag themost recent persisted checkpoint, the returned timestamp isguaranteed to be persisted in a stable checkpoint to disk.
A null
value indicates that no stable checkpoint exists.
New in version 4.0.
New in version 4.2.
For internal use only
New in version 4.2.1.
Metrics related to the election of the current primary.electionCandidateMetrics
is only availableon the primary or a candidate for election. For a candidate, themetrics becomes unavailable once the candidate loses the election.
New in version 4.2.1.
Reason the member called the election.
New in version 4.2.1.
The date and time the member called the election.
New in version 4.2.1.
The member’s election count (i.e. term
)at the time it called for the new election.
New in version 4.2.1.
The most recent majority-committed optime
, as seen by thismember, at the time it called for the new election.
New in version 4.2.1.
The member’s most recent applied optime
at the time it calledfor the new election.
New in version 4.2.1.
The number of votes needed to win the election.
New in version 4.2.1.
The member’s priority
at the timeit called the election.
New in version 4.2.1.
The replica set’s configuredelectionTimeoutMillis
setting at the time ofthe election.
New in version 4.2.1.
The members[n]._id
of the previous primary. Ifthere is no previous primary, then the field is not present.
New in version 4.2.1.
The number of operations applied by the newly-elected primary asit successfully concludes its catchup process.
New in version 4.2.1.
The date and time at which the member’s term as the primarystarted (i.e. the date and time at which a new term
entry waswritten to the oplog).
New in version 4.2.1.
The date and time at which the write concern"majority"
became available after the electionfor the replica set(i.e. the date and time at which the newterm
oplog entry was majority committed).
New in version 3.4.
A document provides information on the progress and status ofinitial sync on this member.
Availability
Starting in MongoDB 4.2.1,replSetGetStatus.initialSyncStatus
metrics are onlyavailable 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 availablewhen the command is run with initialSync: 1
option on asecondary or a member in its STARTUP2
state, even afterthe member completes its initial sync. However, some fields thatrelate to the progress of an on-going initial sync only appear whilethe initial sync is in progress and do not appear once the initialsync completes.
New in version 3.4.
The number of times the initial sync failed and had to restart on thismember.
Availability
Starting in MongoDB 4.2.1,replSetGetStatus.initialSyncStatus
metrics are onlyavailable 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 availablewhen the command is run with initialSync: 1
option on asecondary or a member in its STARTUP2
state, even afterthe member completes its initial sync. However, some fields thatrelate to the progress of an on-going initial sync only appear whilethe initial sync is in progress and do not appear once the initialsync completes.
New in version 3.4.
The maximum number of times the initial sync can restart on this member beforethe member shuts down.
Availability
Starting in MongoDB 4.2.1,replSetGetStatus.initialSyncStatus
metrics are onlyavailable 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 availablewhen the command is run with initialSync: 1
option on asecondary or a member in its STARTUP2
state, even afterthe member completes its initial sync. However, some fields thatrelate to the progress of an on-going initial sync only appear whilethe initial sync is in progress and do not appear once the initialsync completes.
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 onlyavailable 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 availablewhen the command is run with initialSync: 1
option on asecondary or a member in its STARTUP2
state, even afterthe member completes its initial sync. However, some fields thatrelate to the progress of an on-going initial sync only appear whilethe initial sync is in progress and do not appear once the initialsync completes.
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 onlyavailable 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 availablewhen the command is run with initialSync: 1
option on asecondary or a member in its STARTUP2
state, even afterthe member completes its initial sync. However, some fields thatrelate to the progress of an on-going initial sync only appear whilethe initial sync is in progress and do not appear once the initialsync completes.
New in version 3.4.
The number of milliseconds betweeninitialSyncStart
andinitialSyncEnd
.
Availability
Starting in MongoDB 4.2.1,replSetGetStatus.initialSyncStatus
metrics are onlyavailable 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 availablewhen the command is run with initialSync: 1
option on asecondary or a member in its STARTUP2
state, even afterthe member completes its initial sync. However, some fields thatrelate to the progress of an on-going initial sync only appear whilethe initial sync is in progress and do not appear once the initialsync completes.
New in version 3.4.
Array of documents where each document corresponds to a singleinitial sync attempt. See alsofailedInitialSyncAttempts
.
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 onlyavailable 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 availablewhen the command is run with initialSync: 1
option on asecondary or a member in its STARTUP2
state, even afterthe member completes its initial sync. However, some fields thatrelate to the progress of an on-going initial sync only appear whilethe initial sync is in progress and do not appear once the initialsync completes.
New in version 3.4.
The number of missing (i.e. uncloned) documents that were fetchedfrom the sync source in order to apply to those documents theupdates that occurred after the initial sync started.
As part of the initial sync process, the member uses the oplogto update its data set to reflect the current state of thereplica set.
Availability
Starting in MongoDB 4.2.1,replSetGetStatus.initialSyncStatus
metrics are onlyavailable 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 availablewhen the command is run with initialSync: 1
option on asecondary or a member in its STARTUP2
state, even afterthe member completes its initial sync. However, some fields thatrelate to the progress of an on-going initial sync only appear whilethe initial sync is in progress and do not appear once the initialsync completes.
New in version 3.4.
The number of ops that occurred after the initial sync started and were applied after cloningthe databases.
As part of the initial sync process, the member uses the oplogto update its data set to reflect the current state of thereplica set.
Availability
Starting in MongoDB 4.2.1,replSetGetStatus.initialSyncStatus
metrics are onlyavailable 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 availablewhen the command is run with initialSync: 1
option on asecondary or a member in its STARTUP2
state, even afterthe member completes its initial sync. However, some fields thatrelate to the progress of an on-going initial sync only appear whilethe initial sync is in progress and do not appear once the initialsync completes.
New in version 3.4.
The start timestamp of the oplog application stage of theinitial sync where themember applies changes that occurred after the initial syncstart.
As part of the initial sync process, the member uses the oplogto update its data set to reflect the current state of thereplica set.
Availability
Starting in MongoDB 4.2.1,replSetGetStatus.initialSyncStatus
metrics are onlyavailable 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 availablewhen the command is run with initialSync: 1
option on asecondary or a member in its STARTUP2
state, even afterthe member completes its initial sync. However, some fields thatrelate to the progress of an on-going initial sync only appear whilethe initial sync is in progress and do not appear once the initialsync completes.
New in version 3.4.
The end timestamp of the oplog application stage of theinitial sync where themember applies changes that occurred after the initial syncstart.
As part of the initial sync process, the member uses the oplogto update its data set to reflect the current state of thereplica set.
Availability
Starting in MongoDB 4.2.1,replSetGetStatus.initialSyncStatus
metrics are onlyavailable 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 availablewhen the command is run with initialSync: 1
option on asecondary or a member in its STARTUP2
state, even afterthe member completes its initial sync. However, some fields thatrelate to the progress of an on-going initial sync only appear whilethe initial sync is in progress and do not appear once the initialsync completes.
New in version 3.4.
Detail on the databases cloned during initial sync.
Availability
Starting in MongoDB 4.2.1,replSetGetStatus.initialSyncStatus
metrics are onlyavailable 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 availablewhen the command is run with initialSync: 1
option on asecondary or a member in its STARTUP2
state, even afterthe member completes its initial sync. However, some fields thatrelate to the progress of an on-going initial sync only appear whilethe initial sync is in progress and do not appear once the initialsync completes.
New in version 3.4.
Number of databases cloned during initial sync.
Availability
Starting in MongoDB 4.2.1,replSetGetStatus.initialSyncStatus
metrics are onlyavailable 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 availablewhen the command is run with initialSync: 1
option on asecondary or a member in its STARTUP2
state, even afterthe member completes its initial sync. However, some fields thatrelate to the progress of an on-going initial sync only appear whilethe initial sync is in progress and do not appear once the initialsync completes.
New in version 3.4.
For each database, a document that returns information regardingthe 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 onlyavailable 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 availablewhen the command is run with initialSync: 1
option on asecondary or a member in its STARTUP2
state, even afterthe member completes its initial sync. However, some fields thatrelate to the progress of an on-going initial sync only appear whilethe initial sync is in progress and do not appear once the initialsync completes.
replSetGetStatus.
members
The
members
field holds an array that contains a document forevery member in the replica set.replSetGetStatus.members[n].
_id
The identifier for the member.
The name of the member.
- The resolved IP address of the member. If the
mongod
is unable to resolve thereplSetGetStatus.members[n].name
to an IP address, thereturn value is a BSON null. Otherwise, the returned value is astring representation of the resolved IP address.
New in version 4.2.
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 thecurrent mongod
instance, and as such, its value is alwaystrue
.
replSetGetStatus.members[n].
health
- A number that indicates if the member is up (i.e.
1
) or down(i.e.0
).
The health
value is only present for the other members of thereplica set (i.e. not the member on which thers.status()
is run).
replSetGetStatus.members[n].
state
An integer between
0
and10
that represents thereplica state of the member.A string that describes
state
.- The
uptime
field holds a valuethat reflects the number of seconds that this member has beenonline.
This value does not appear for the member that returns thers.status()
data.
replSetGetStatus.members[n].
optime
- Information regarding the last operation from the operation log thatthis member has applied.
Changed in version 3.2.
optime
returns a document that contains:
- <code>ts</code>, the [Timestamp]($a7c1e8e12192a4b0.md#document-bson-type-timestamp) ofthe last operation applied to this member of the replica setfrom the [oplog]($9b2cb11cb0f69078.md#term-oplog).
- <code>t</code>, the [<code>term</code>]($f569861c36592706.md#replSetGetStatus.term) in which the lastapplied operation was originally generated on the primary.
New in version 3.4.
Information regarding the last operation from the operation logthat this member has applied to its journal.
optimeDurable
returns a document that contains:
- <code>ts</code>, the [Timestamp]($a7c1e8e12192a4b0.md#document-bson-type-timestamp) ofthe operation.
- <code>t</code>, the [<code>term</code>]($f569861c36592706.md#replSetGetStatus.term) in which thisoperation was originally generated on the primary.
replSetGetStatus.members[n].
optimeDate
An ISODate formatted date string that reflects the lastentry from the oplog that this member applied. If thisdiffers significantly from
lastHeartbeat
this member iseither experiencing “replication lag” or there have not been anynew operations since the last update. Comparemembers.optimeDate
between all of the members of the set.
New in version 3.4.
An ISODate formatted date string that reflects the lastentry from the oplog that this member applied to itsjournal.
replSetGetStatus.members[n].
electionTime
For the current primary, information regarding the electionTimestamp from theoperation log. See Replica Set High Availability for moreinformation about elections.
For the current primary, an ISODate formatted date stringthat reflects the election date. SeeReplica Set High Availability for more information aboutelections.
Indicates which replica set member processed thereplSetGetStatus command.
- An ISODate formatted date and time that reflects the lasttime the server that processed the replSetGetStatuscommand received a response from a heartbeat that it sent to thismember (
members[n]
).Compare this value to the values of thedate
andlastHeartBeatRecv
fields totrack 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 lasttime the server that processed the replSetGetStatuscommand received a heartbeat request from this member(
members[n]
).Compare this value to the values of thedate
andlastHeartBeat
fields to tracklatency 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
containsa string representation of that message.- The
pingMs
represents the number of milliseconds (ms) that around-trip packet takes to travel between the remote member andthe local instance.
This value does not appear for the member that returns thers.status()
data.
Deprecated since version 4.0,: 3.6.6, 3.4.16
Starting in MongoDB 4.0 (and 3.6.6, 3.4.16), MongoDB deprecatessyncingTo
. SeereplSetGetStatus.members[n].syncSourceHost
instead.
The syncingTo
field holds the hostname of the member fromwhich this instance is syncing. If the member is a primary,returns an empty string ""
.
New in version 4.0,: 3.6.6, 3.4.16
The syncSourceHost
fieldholds the hostname of the member from which this instance syncs.
If the replSetGetStatus.members[n]
is a primary,syncSourceHost
is an emptystring and the syncSourceId
-1
.
New in version 4.0,: 3.6.6, 3.4.16
The syncSourceId
field holdsthe replSetGetStatus.members[n]._id
value of thesyncSourceHost
.
If the replSetGetStatus.members[n]
is a primary,syncSourceHost
is an emptystring and the syncSourceId
-1
.
New in version 3.0.
The configVersion
value is the replicaset configuration version
.
See also Response for details on the ok
statusfield, the operationTime
field and the $clusterTime
field.