Docs Home → Develop Applications → MongoDB Manual
replSetGetStatus![](/docs/v5.2/assets/link.svg)
On this page
Definition![](/docs/v5.2/assets/link.svg)
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 forreplSetGetStatus
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.
Syntax![](/docs/v5.2/assets/link.svg)
The command has the following syntax:
db.adminCommand( { replSetGetStatus: 1 } )
- Starting in MongoDB 4.2.1
If you run
replSetGetStatus
or themongosh
helperrs.status()
on a member during its initial sync (i.e.STARTUP2
state), the command returnsreplSetGetStatus.initialSyncStatus
metrics.Once the member finishes its initial sync and transitions to another state, the
replSetGetStatus.initialSyncStatus
metrics are no longer available.
- In earlier versions (3.6.x-4.2.0)
To return initial sync status information, include
initialSync: 1
in the command on a secondary member or a member inSTARTUP2
state:db.adminCommand( { replSetGetStatus: 1, initialSync: 1 } ) The
replSetGetStatus.initialSyncStatus
metrics remains available after the member completes its initial sync. That is, you can run thereplSetGetStatus
command with theinitialSync: 1
on the secondary member to return its initial sync information.You cannot specify
initialSync: 1
in themongosh
helperrs.status()
.
Example![](/docs/v5.2/assets/link.svg)
Output![](/docs/v5.2/assets/link.svg)
The replSetGetStatus command returns a document with the following 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 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
and10
that represents the replica state of the current member.
replSetGetStatus.term
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
Removed in MongoDB 4.4
See
replSetGetStatus.syncSourceHost
instead.
replSetGetStatus.syncSourceHost
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 thesyncSourceId
-1
.
replSetGetStatus.syncSourceId
The
syncSourceId
field holds thereplSetGetStatus.members[n]._id
of the member from which this instance syncs.If this instance is a primary,
syncSourceHost
is an empty string and thesyncSourceId
-1
.
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.votingMembersCount
New in version 4.4.
The number of members configured with
votes: 1
, including arbiters.
replSetGetStatus.writableVotingMembersCount
New in version 4.4.
The number of data-bearing members configured with
votes: 1
; that is, the count does not include arbiters.
replSetGetStatus.optimes
The
optimes
field holds a document that contains optimes used to inspect replication progress. Starting in MongoDB 4.2, theoptimes
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
, theterm
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 reflectlastCommittedOpTime
if all members 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 the most recent operation that can fulfill read concern
"majority"
queries; i.e. the most recentlastCommittedOpTime
that can fulfill"majority"
queries.readConcernMajorityOpTime
is either less than or equal tolastCommittedOpTime
.
replSetGetStatus.optimes.readConcernMajorityWallTime
The ISODate-formatted date string corresponding to
readConcernMajorityOpTime
.The
readConcernMajorityWallTime
may not accurately reflectreadConcernMajorityOpTime
if all 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 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.
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 namedelectionTerm
.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 thenew 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.initialSyncStatus
A document that provides information on the progress and status of initial sync on this member.
Important
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.6.x-4.2.0),
replSetGetStatus.initialSyncStatus
metrics are available when the command is run withinitialSync: 1
option on a secondary or a member in itsSTARTUP2
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
The number of times the initial sync failed and had to restart on this member.
replSetGetStatus.initialSyncStatus.maxFailedInitialSyncAttempts
The maximum number of times the initial sync can restart on this member before the member shuts down.
replSetGetStatus.initialSyncStatus.initialSyncStart
The start timestamp of the initial sync for this member.
replSetGetStatus.initialSyncStatus.initialSyncEnd
The end timestamp of the initial sync for this member.
replSetGetStatus.initialSyncStatus.initialSyncElapsedMillis
The number of milliseconds between
initialSyncStart
andinitialSyncEnd
.
replSetGetStatus.initialSyncStatus.initialSyncAttempts
Array of documents where each document corresponds to a single initial sync attempt. For example:
"initialSyncAttempts" : [ { "durationMillis" : 59539, "status" : "InvalidOptions: error fetching oplog during initial sync :: caused by :: Error while getting the next batch in the oplog fetcher :: caused by :: readConcern afterClusterTime value must not be greater than the current clusterTime. Requested clusterTime: { ts: Timestamp(0, 1) }; current clusterTime: { ts: Timestamp(0, 0) }", "syncSource" : "m1.example.net:27017", "rollBackId" : 1, // Available starting in v4.4 "operationsRetried" : 120, // Available starting in v4.4 "totalTimeUnreachableMillis" : 52601 // Available starting in v4.4 } ], Each document contains the following information for the initial sync attempt:
FieldDescriptiondurationMillisDuration in milliseconds of the initial sync attempt.statusExit status of the initial sync attempt.syncSourceSync source for the initial sync attempt.rollBackIdThe sync source's rollback identifier at the start of the initial sync attempt.
rollBackId
does not appear when using file copy based initial sync.New in version 4.4.
operationsRetriedTotal number of all operation retry attempts.
New in version 4.4.
totalTimeUnreachableMillisTotal time spent for retry operation attempts.
New in version 4.4.
See also
failedInitialSyncAttempts
.
replSetGetStatus.initialSyncStatus.appliedOps
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.
replSetGetStatus.initialSyncStatus.initialSyncOplogStart
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.
replSetGetStatus.initialSyncStatus.initialSyncOplogEnd
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.
replSetGetStatus.initialSyncStatus.syncSourceUnreachableSince
The date and time at which the sync source became unreachable.
Only present if the if sync source is unavailable during the current initial sync.
New in version 4.4.
replSetGetStatus.initialSyncStatus.currentOutageDurationMillis
The time in milliseconds that the sync source has been unavailable.
Only present if the if sync source is unavailable during the current initial sync.
New in version 4.4.
replSetGetStatus.initialSyncStatus.totalTimeUnreachableMillis
The total time in milliseconds that the member has been unavailable during the current initial sync.
New in version 4.4.
replSetGetStatus.initialSyncStatus.databases
Detail on the databases cloned during initial sync.
replSetGetStatus.initialSyncStatus.databases.databasesCloned
Number of databases cloned during initial sync.
replSetGetStatus.initialSyncStatus.databases.<dbname>
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 } }
replSetGetStatus.initialSyncStatus.method
New in version 5.2.
The method used for the initial sync.
If set to
logical
, the sync is a logical initial sync. If set tofileCopyBased
, the sync is a file copy based initial sync.
replSetGetStatus.initialSyncStatus.approxTotalDataSize
The approximate size (in bytes) of all files to be synced during file copy based initial sync.
This field only appears when using file copy based initial sync.
replSetGetStatus.initialSyncStatus.approxTotalBytesCopied
The total bytes already copied.
This field only appears when using file copy based initial sync.
replSetGetStatus.initialSyncStatus.totalInitialSyncElapsedMillis
The total time elapsed for the sync attempt in progress.
This field only appears when using file copy based initial sync.
replSetGetStatus.initialSyncStatus.remainingInitialSyncEstimatedMillis
The expected time remaining for the sync attempt in progress.
This field only appears when using file copy based initial sync.
replSetGetStatus.initialSyncStatus.initialBackupDataSize
The total size (in bytes) of the initial set of files to be synced.
This field only appears when using file copy based initial sync.
replSetGetStatus.initialSyncStatus.previousOplogEnd
The optime available in the previous backup cursor.
This field only appears when using file copy based initial sync.
replSetGetStatus.initialSyncStatus.currentOplogEnd
The last optime guaranteed to be available in the current backup cursor.
This field only appears when using file copy based initial sync.
replSetGetStatus.initialSyncStatus.syncSourceLastApplied
The optime of the last update applied at the sync source prior to the start of this backup cursor.
This field only appears when using file copy based initial sync.
replSetGetStatus.initialSyncStatus.numExtensions
The number of times the sync has started a new backup cursor.
This field does not appear if a backup cursor has not started.
This field only appears when using file copy based initial sync.
replSetGetStatus.initialSyncStatus.extensionDataSize
The total bytes in the current extension.
This field does not appear if there is no extension in progress.
This field only appears when using file copy based initial sync.
replSetGetStatus.initialSyncStatus.files
An array of files to be synced during file copy based initial sync.
This field only appears when using file copy based initial sync.
replSetGetStatus.initialSyncStatus.files[n].filePath
The path of the file relative to the root of the backup cursor.
This field only appears when using file copy based initial sync.
replSetGetStatus.initialSyncStatus.files[n].fileSize
The size of the file as reported by the backup cursor.
This field only appears when using file copy based initial sync.
replSetGetStatus.initialSyncStatus.files[n].bytesCopied
The number of bytes copied so far.
This field only appears when using file copy based initial sync.
replSetGetStatus.initialSyncStatus.files[n].extensionNumber
The number of the extension the file belongs to if this file is part of an extension.
This field only appears when using file copy based initial sync.
replSetGetStatus.members
The
members
field holds an array that contains a document for every member in the replica set.replSetGetStatus.members[n].ip
The resolved IP address of the member. If the
mongod
is unable to resolve thereplSetGetStatus.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.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 the currentmongod
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
).
replSetGetStatus.members[n].state
An integer between
0
and10
that represents the replica state of the member.
replSetGetStatus.members[n].stateStr
A string that describes
state
.
replSetGetStatus.members[n].uptime
The
uptime
field holds a value that reflects the number of seconds that this member has been online.This value does not appear for the member that returns the
rs.status()
data.
replSetGetStatus.members[n].optime
Information regarding the last operation from the operation log that this member has applied.
optime
returns a document that contains:
replSetGetStatus.members[n].optimeDurable
Information regarding the last operation from the operation log that this member has applied to its journal.
optimeDurable
returns a document that contains:
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. Comparemembers.optimeDate
between all of the members of the set.
replSetGetStatus.members[n].optimeDurableDate
An ISODate formatted date string that reflects the last entry from the oplog that this member applied to its journal.
replSetGetStatus.members[n].lastAppliedWallTime
An ISODate formatted date string reflecting the wall clock time at which the last operation applied by this member of the replica set was applied on the primary node.
replSetGetStatus.members[n].lastDurableWallTime
An ISODate formatted date string reflecting the wall clock time at which the last operation written to this member's journal was first applied on the primary node.
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].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 thedate
andlastHeartbeatRecv
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 thedate
andlastHeartbeat
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
Removed in MongoDB 4.4
See
replSetGetStatus.members[n].syncSourceHost
instead.
replSetGetStatus.members[n].syncSourceHost
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 thesyncSourceId
-1
.
replSetGetStatus.members[n].syncSourceId
The
syncSourceId
field holds thereplSetGetStatus.members[n]._id
value of thesyncSourceHost
.If the
replSetGetStatus.members[n]
is a primary,syncSourceHost
is an empty string and thesyncSourceId
-1
.
replSetGetStatus.members[n].configVersion
The
configVersion
value is thereplica set configuration version
.
replSetGetStatus.tooStale
A boolean which indicates that a replica set member has fallen too far behind the primary's oplog and is stuck in the
RECOVERING
state. This field is only included in thereplSetGetStatus
output if its value istrue
.New in version 4.4.
See also Response for details on the ok
status
field, the operationTime
field and the $clusterTime
field.