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:

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

Once the member finishes its initial sync and transitions toanother state, the replSetGetStatus.initialSyncStatusmetrics 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 in STARTUP2 state:
  1. 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 mongoshell helper rs.status().

Example

  • Primary
  • Secondary
  • Include Initial Sync Metrics

The following example runs the replSetGetStatuscommand on the admin database of the replica setprimary:

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

The command returns the following output for an examplereplica set primary:

  1. {
  2. "set" : "replset",
  3. "date" : ISODate("2019-10-14T15:09:28.182Z"),
  4. "myState" : 1,
  5. "term" : NumberLong(1),
  6. "syncingTo" : "",
  7. "syncSourceHost" : "",
  8. "syncSourceId" : -1,
  9. "heartbeatIntervalMillis" : NumberLong(2000),
  10. "majorityVoteCount" : 2, // Available starting in 4.2.1
  11. "writeMajorityCount" : 2, // Available starting in 4.2.1
  12. "optimes" : {
  13. "lastCommittedOpTime" : {
  14. "ts" : Timestamp(1571065766, 1),
  15. "t" : NumberLong(1)
  16. },
  17. "lastCommittedWallTime" : ISODate("2019-10-14T15:09:26.120Z"),
  18. "readConcernMajorityOpTime" : {
  19. "ts" : Timestamp(1571065766, 1),
  20. "t" : NumberLong(1)
  21. },
  22. "readConcernMajorityWallTime" : ISODate("2019-10-14T15:09:26.120Z"),
  23. "appliedOpTime" : {
  24. "ts" : Timestamp(1571065766, 1),
  25. "t" : NumberLong(1)
  26. },
  27. "durableOpTime" : {
  28. "ts" : Timestamp(1571065766, 1),
  29. "t" : NumberLong(1)
  30. },
  31. "lastAppliedWallTime" : ISODate("2019-10-14T15:09:26.120Z"),
  32. "lastDurableWallTime" : ISODate("2019-10-14T15:09:26.120Z")
  33. },
  34. "lastStableRecoveryTimestamp" : Timestamp(1571065746, 2),
  35. "lastStableCheckpointTimestamp" : Timestamp(1571065746, 2),
  36. "electionCandidateMetrics" : {
  37. "lastElectionReason" : "electionTimeout",
  38. "lastElectionDate" : ISODate("2019-10-14T15:09:05.328Z"),
  39. "termAtElection" : NumberLong(1),
  40. "lastCommittedOpTimeAtElection" : {
  41. "ts" : Timestamp(0, 0),
  42. "t" : NumberLong(-1)
  43. },
  44. "lastSeenOpTimeAtElection" : {
  45. "ts" : Timestamp(1571065734, 1),
  46. "t" : NumberLong(-1)
  47. },
  48. "numVotesNeeded" : 2,
  49. "priorityAtElection" : 1,
  50. "electionTimeoutMillis" : NumberLong(10000),
  51. "numCatchUpOps" : NumberLong(0),
  52. "newTermStartDate" : ISODate("2019-10-14T15:09:06.115Z"),
  53. "wMajorityWriteAvailabilityDate" : ISODate("2019-10-14T15:09:07.333Z")
  54. },
  55. "members" : [
  56. {
  57. "_id" : 0,
  58. "name" : "m1.example.net:27017",
  59. "ip" : "198.51.100.1",
  60. "health" : 1,
  61. "state" : 1,
  62. "stateStr" : "PRIMARY",
  63. "uptime" : 417,
  64. "optime" : {
  65. "ts" : Timestamp(1571066144, 1),
  66. "t" : NumberLong(1)
  67. },
  68. "optimeDate" : ISODate("2019-10-14T15:15:44Z"),
  69. "syncingTo" : "",
  70. "syncSourceHost" : "",
  71. "syncSourceId" : -1,
  72. "infoMessage" : "",
  73. "electionTime" : Timestamp(1571065745, 1),
  74. "electionDate" : ISODate("2019-10-14T15:09:05Z"),
  75. "configVersion" : 1,
  76. "self" : true,
  77. "lastHeartbeatMessage" : ""
  78. },
  79. {
  80. "_id" : 1,
  81. "name" : "m2.example.net:27017",
  82. "ip" : "198.51.100.2",
  83. "health" : 1,
  84. "state" : 2,
  85. "stateStr" : "SECONDARY",
  86. "uptime" : 414,
  87. "optime" : {
  88. "ts" : Timestamp(1571066144, 1),
  89. "t" : NumberLong(1)
  90. },
  91. "optimeDurable" : {
  92. "ts" : Timestamp(1571066144, 1),
  93. "t" : NumberLong(1)
  94. },
  95. "optimeDate" : ISODate("2019-10-14T15:15:44Z"),
  96. "optimeDurableDate" : ISODate("2019-10-14T15:15:44Z"),
  97. "lastHeartbeat" : ISODate("2019-10-14T15:15:47.723Z"),
  98. "lastHeartbeatRecv" : ISODate("2019-10-14T15:15:47.586Z"),
  99. "pingMs" : NumberLong(0),
  100. "lastHeartbeatMessage" : "",
  101. "syncingTo" : "m1.example.net:27017",
  102. "syncSourceHost" : "m1.example.net:27017",
  103. "syncSourceId" : 0,
  104. "infoMessage" : "",
  105. "configVersion" : 1
  106. },
  107. {
  108. "_id" : 2,
  109. "name" : "m3.example.net:27017",
  110. "ip" : "198.51.100.3",
  111. "health" : 1,
  112. "state" : 2,
  113. "stateStr" : "SECONDARY",
  114. "uptime" : 414,
  115. "optime" : {
  116. "ts" : Timestamp(1571066144, 1),
  117. "t" : NumberLong(1)
  118. },
  119. "optimeDurable" : {
  120. "ts" : Timestamp(1571066144, 1),
  121. "t" : NumberLong(1)
  122. },
  123. "optimeDate" : ISODate("2019-10-14T15:15:44Z"),
  124. "optimeDurableDate" : ISODate("2019-10-14T15:15:44Z"),
  125. "lastHeartbeat" : ISODate("2019-10-14T15:15:47.723Z"),
  126. "lastHeartbeatRecv" : ISODate("2019-10-14T15:15:47.612"),
  127. "pingMs" : NumberLong(0),
  128. "lastHeartbeatMessage" : "",
  129. "syncingTo" : "m1.example.net:27017",
  130. "syncSourceHost" : "m1.example.net:27017",
  131. "syncSourceId" : 0,
  132. "infoMessage" : "",
  133. "configVersion" : 1
  134. }
  135. ],
  136. "ok" : 1,
  137. "$clusterTime" : {
  138. "clusterTime" : Timestamp(1571066144, 1),
  139. "signature" : {
  140. "hash" : BinData(0,"7KPhkSeNOAlrA081F16Xl30ljOU="),
  141. "keyId" : NumberLong("6747675998935842818")
  142. }
  143. },
  144. "operationTime" : Timestamp(1571066144, 1)
  145. }

The following example runs the replSetGetStatuscommand on the admin database of the replica setsecondary.

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

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

  1. {
  2. "set" : "replset",
  3. "date" : ISODate("2019-10-15T04:28:13.318Z"),
  4. "myState" : 2,
  5. "term" : NumberLong(1),
  6. "syncingTo" : "m2.example.net:27017",
  7. "syncSourceHost" : "m2.example.net:27017",
  8. "syncSourceId" : 1,
  9. "heartbeatIntervalMillis" : NumberLong(2000),
  10. "majorityVoteCount" : 2, // Available starting in 4.2.1
  11. "writeMajorityCount" : 2, // Available starting in 4.2.1
  12. "optimes" : {
  13. "lastCommittedOpTime" : {
  14. "ts" : Timestamp(1571113692, 1),
  15. "t" : NumberLong(1)
  16. },
  17. "lastCommittedWallTime" : ISODate("2019-10-15T04:28:12.660Z"),
  18. "readConcernMajorityOpTime" : {
  19. "ts" : Timestamp(1571113692, 1),
  20. "t" : NumberLong(1)
  21. },
  22. "readConcernMajorityWallTime" : ISODate("2019-10-15T04:28:12.660Z"),
  23. "appliedOpTime" : {
  24. "ts" : Timestamp(1571113692, 1),
  25. "t" : NumberLong(1)
  26. },
  27. "durableOpTime" : {
  28. "ts" : Timestamp(1571113692, 1),
  29. "t" : NumberLong(1)
  30. },
  31. "lastAppliedWallTime" : ISODate("2019-10-15T04:28:12.660Z"),
  32. "lastDurableWallTime" : ISODate("2019-10-15T04:28:12.660Z")
  33. },
  34. "lastStableRecoveryTimestamp" : Timestamp(1571113662, 1),
  35. "lastStableCheckpointTimestamp" : Timestamp(1571113662, 1),
  36. "members" : [
  37. {
  38. "_id" : 0,
  39. "name" : "m1.example.net:27017",
  40. "ip" : "198.51.100.1",
  41. "health" : 1,
  42. "state" : 1,
  43. "stateStr" : "PRIMARY",
  44. "uptime" : 178,
  45. "optime" : {
  46. "ts" : Timestamp(1571113682, 1),
  47. "t" : NumberLong(1)
  48. },
  49. "optimeDurable" : {
  50. "ts" : Timestamp(1571113682, 1),
  51. "t" : NumberLong(1)
  52. },
  53. "optimeDate" : ISODate("2019-10-15T04:28:02Z"),
  54. "optimeDurableDate" : ISODate("2019-10-15T04:28:02Z"),
  55. "lastHeartbeat" : ISODate("2019-10-15T04:28:11.857Z"),
  56. "lastHeartbeatRecv" : ISODate("2019-10-15T04:28:13.043Z"),
  57. "pingMs" : NumberLong(0),
  58. "lastHeartbeatMessage" : "",
  59. "syncingTo" : "",
  60. "syncSourceHost" : "",
  61. "syncSourceId" : -1,
  62. "infoMessage" : "",
  63. "electionTime" : Timestamp(1571113240, 1),
  64. "electionDate" : ISODate("2019-10-15T04:20:40Z"),
  65. "configVersion" : 2
  66. },
  67. {
  68. "_id" : 1,
  69. "name" : "m2.example.net:27017",
  70. "ip" : "198.51.100.2",
  71. "health" : 1,
  72. "state" : 2,
  73. "stateStr" : "SECONDARY",
  74. "uptime" : 178,
  75. "optime" : {
  76. "ts" : Timestamp(1571113682, 1),
  77. "t" : NumberLong(1)
  78. },
  79. "optimeDurable" : {
  80. "ts" : Timestamp(1571113682, 1),
  81. "t" : NumberLong(1)
  82. },
  83. "optimeDate" : ISODate("2019-10-15T04:28:02Z"),
  84. "optimeDurableDate" : ISODate("2019-10-15T04:28:02Z"),
  85. "lastHeartbeat" : ISODate("2019-10-15T04:28:11.857Z"),
  86. "lastHeartbeatRecv" : ISODate("2019-10-15T04:28:13.310Z"),
  87. "pingMs" : NumberLong(0),
  88. "lastHeartbeatMessage" : "",
  89. "syncingTo" : "m1.example.net:27017",
  90. "syncSourceHost" : "m1.example.net:27017",
  91. "syncSourceId" : 0,
  92. "infoMessage" : "",
  93. "configVersion" : 2
  94. },
  95. {
  96. "_id" : 2,
  97. "name" : "m3.example.net:27017",
  98. "ip" : "198.51.100.3",
  99. "health" : 1,
  100. "state" : 2,
  101. "stateStr" : "SECONDARY",
  102. "uptime" : 465,
  103. "optime" : {
  104. "ts" : Timestamp(1571113692, 1),
  105. "t" : NumberLong(1)
  106. },
  107. "optimeDate" : ISODate("2019-10-15T04:28:12Z"),
  108. "syncingTo" : "m2.example.net:27017",
  109. "syncSourceHost" : "m2.example.net:27017",
  110. "syncSourceId" : 1,
  111. "infoMessage" : "",
  112. "configVersion" : 2,
  113. "self" : true,
  114. "lastHeartbeatMessage" : ""
  115. }
  116. ],
  117. "ok" : 1,
  118. "$clusterTime" : {
  119. "clusterTime" : Timestamp(1571113692, 1),
  120. "signature" : {
  121. "hash" : BinData(0,"YBSGbOPTeazPhppu6WnyVRZwYms="),
  122. "keyId" : NumberLong("6747879992702533634")
  123. }
  124. },
  125. "operationTime" : Timestamp(1571113692, 1)
  126. }
  • In earlier versions (3.4.x-4.2.0)
  • You can include the optional initialSync: 1 to includethe replSetGetStatus.initialSyncStatus in theoutput (you can omit if you do not want to return theinitial sync status):
  1. db.adminCommand( { replSetGetStatus : 1, initialSync: 1} )
  1. db.adminCommand( { replSetGetStatus : 1} )

Once the member finishes its initial sync and transitions toanother state,the replSetGetStatus.initialSyncStatusmetrics is no longer available.

  • In earlier versions (3.4.x-4.2.0)
  • You can include the optional initialSync: 1 to includethe replSetGetStatus.initialSyncStatus in theoutput (you can omit if you do not want to return theinitial sync status):
  1. 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 replSetGetStatuscommand with the initialSync: 1 on the secondarymember to return its initial sync information.

The following example runs the replSetGetStatuscommand on the admin database of the 4.2.1 replicaset member during its initial sync:

  1. {
  2. "set" : "replset",
  3. "date" : ISODate("2019-10-15T01:26:38.743Z"),
  4. "myState" : 5,
  5. "term" : NumberLong(1),
  6. "syncingTo" : "m2.example.net:27017",
  7. "syncSourceHost" : "m2.example.net:27017",
  8. "syncSourceId" : 1,
  9. "heartbeatIntervalMillis" : NumberLong(2000),
  10. "majorityVoteCount" : 2,
  11. "writeMajorityCount" : 2,
  12. "optimes" : {
  13. "lastCommittedOpTime" : {
  14. "ts" : Timestamp(0, 0),
  15. "t" : NumberLong(-1)
  16. },
  17. "lastCommittedWallTime" : ISODate("1970-01-01T00:00:00Z"),
  18. "appliedOpTime" : {
  19. "ts" : Timestamp(0, 0),
  20. "t" : NumberLong(-1)
  21. },
  22. "durableOpTime" : {
  23. "ts" : Timestamp(0, 0),
  24. "t" : NumberLong(-1)
  25. },
  26. "lastAppliedWallTime" : ISODate("1970-01-01T00:00:00Z"),
  27. "lastDurableWallTime" : ISODate("1970-01-01T00:00:00Z")
  28. },
  29. "lastStableRecoveryTimestamp" : Timestamp(0, 0),
  30. "lastStableCheckpointTimestamp" : Timestamp(0, 0),
  31. "initialSyncStatus" : {
  32. "failedInitialSyncAttempts" : 0,
  33. "maxFailedInitialSyncAttempts" : 10,
  34. "initialSyncStart" : ISODate("2019-10-15T01:25:40.989Z"),
  35. "initialSyncAttempts" : [ ],
  36. "fetchedMissingDocs" : 0,
  37. "appliedOps" : 0,
  38. "initialSyncOplogStart" : Timestamp(1571102740, 1),
  39. "databases" : {
  40. "databasesCloned" : 2,
  41. "admin" : {
  42. "collections" : 4,
  43. "clonedCollections" : 4,
  44. "start" : ISODate("2019-10-15T01:25:41.154Z"),
  45. "end" : ISODate("2019-10-15T01:25:41.848Z"),
  46. "elapsedMillis" : 694,
  47. "admin.system.keys" : {
  48. "documentsToCopy" : 2,
  49. "documentsCopied" : 2,
  50. "indexes" : 1,
  51. "fetchedBatches" : 1,
  52. "start" : ISODate("2019-10-15T01:25:41.156Z"),
  53. "end" : ISODate("2019-10-15T01:25:41.275Z"),
  54. "elapsedMillis" : 119,
  55. "receivedBatches" : 1
  56. },
  57. "admin.system.version" : {
  58. "documentsToCopy" : 2,
  59. "documentsCopied" : 2,
  60. "indexes" : 1,
  61. "fetchedBatches" : 1,
  62. "start" : ISODate("2019-10-15T01:25:41.275Z"),
  63. "end" : ISODate("2019-10-15T01:25:41.382Z"),
  64. "elapsedMillis" : 107,
  65. "receivedBatches" : 1
  66. },
  67. "admin.system.users" : {
  68. "documentsToCopy" : 22,
  69. "documentsCopied" : 22,
  70. "indexes" : 2,
  71. "fetchedBatches" : 1,
  72. "start" : ISODate("2019-10-15T01:25:41.382Z"),
  73. "end" : ISODate("2019-10-15T01:25:41.609Z"),
  74. "elapsedMillis" : 227,
  75. "receivedBatches" : 1
  76. },
  77. "admin.system.roles" : {
  78. "documentsToCopy" : 12,
  79. "documentsCopied" : 12,
  80. "indexes" : 2,
  81. "fetchedBatches" : 1,
  82. "start" : ISODate("2019-10-15T01:25:41.609Z"),
  83. "end" : ISODate("2019-10-15T01:25:41.848Z"),
  84. "elapsedMillis" : 239,
  85. "receivedBatches" : 1
  86. }
  87. },
  88. "config" : {
  89. "collections" : 2,
  90. "clonedCollections" : 2,
  91. "start" : ISODate("2019-10-15T01:25:41.848Z"),
  92. "end" : ISODate("2019-10-15T01:25:42.243Z"),
  93. "elapsedMillis" : 395,
  94. "config.transactions" : {
  95. "documentsToCopy" : 0,
  96. "documentsCopied" : 0,
  97. "indexes" : 1,
  98. "fetchedBatches" : 0,
  99. "start" : ISODate("2019-10-15T01:25:41.849Z"),
  100. "end" : ISODate("2019-10-15T01:25:42.010Z"),
  101. "elapsedMillis" : 161,
  102. "receivedBatches" : 0
  103. },
  104. "config.system.sessions" : {
  105. "documentsToCopy" : 1,
  106. "documentsCopied" : 1,
  107. "indexes" : 2,
  108. "fetchedBatches" : 1,
  109. "start" : ISODate("2019-10-15T01:25:42.009Z"),
  110. "end" : ISODate("2019-10-15T01:25:42.243Z"),
  111. "elapsedMillis" : 234,
  112. "receivedBatches" : 1
  113. }
  114. },
  115. "test" : {
  116. "collections" : 1,
  117. "clonedCollections" : 0,
  118. "start" : ISODate("2019-10-15T01:25:42.243Z"),
  119. "test.hugeindex" : {
  120. "documentsToCopy" : 25000,
  121. "documentsCopied" : 22167,
  122. "indexes" : 2,
  123. "fetchedBatches" : 18,
  124. "start" : ISODate("2019-10-15T01:25:42.244Z"),
  125. "receivedBatches" : 19
  126. }
  127. }
  128. }
  129. },
  130. "lastStableRecoveryTimestamp" : Timestamp(1571066406, 1),
  131. "lastStableCheckpointTimestamp" : Timestamp(1571066406, 1),
  132. "members" : [
  133. {
  134. "_id" : 0,
  135. "name" : "m1.example.net:27017",
  136. "ip" : "198.51.100.1",
  137. "health" : 1,
  138. "state" : 1,
  139. "stateStr" : "PRIMARY",
  140. "uptime" : 57,
  141. "optime" : {
  142. "ts" : Timestamp(1571102795, 1),
  143. "t" : NumberLong(1)
  144. },
  145. "optimeDurable" : {
  146. "ts" : Timestamp(1571102795, 1),
  147. "t" : NumberLong(1)
  148. },
  149. "optimeDate" : ISODate("2019-10-15T01:26:35Z"),
  150. "optimeDurableDate" : ISODate("2019-10-15T01:26:35Z"),
  151. "lastHeartbeat" : ISODate("2019-10-15T01:26:37.531Z"),
  152. "lastHeartbeatRecv" : ISODate("2019-10-15T01:26:38.697Z"),
  153. "pingMs" : NumberLong(0),
  154. "lastHeartbeatMessage" : "",
  155. "syncingTo" : "",
  156. "syncSourceHost" : "",
  157. "syncSourceId" : -1,
  158. "infoMessage" : "",
  159. "electionTime" : Timestamp(1571101495, 1),
  160. "electionDate" : ISODate("2019-10-15T01:04:55Z"),
  161. "configVersion" : 2
  162. },
  163. {
  164. "_id" : 1,
  165. "name" : "m2.example.net:27017",
  166. "ip" : "198.51.100.2",
  167. "health" : 1,
  168. "state" : 2,
  169. "stateStr" : "SECONDARY",
  170. "uptime" : 57,
  171. "optime" : {
  172. "ts" : Timestamp(1571102795, 1),
  173. "t" : NumberLong(1)
  174. },
  175. "optimeDurable" : {
  176. "ts" : Timestamp(1571102795, 1),
  177. "t" : NumberLong(1)
  178. },
  179. "optimeDate" : ISODate("2019-10-15T01:26:35Z"),
  180. "optimeDurableDate" : ISODate("2019-10-15T01:26:35Z"),
  181. "lastHeartbeat" : ISODate("2019-10-15T01:26:37.531Z"),
  182. "lastHeartbeatRecv" : ISODate("2019-10-15T01:26:36.981Z"),
  183. "pingMs" : NumberLong(0),
  184. "lastHeartbeatMessage" : "",
  185. "syncingTo" : "m1.example.net:27017",
  186. "syncSourceHost" : "m1.example.net:27017",
  187. "syncSourceId" : 0,
  188. "infoMessage" : "",
  189. "configVersion" : 2
  190. },
  191. {
  192. "_id" : 2,
  193. "name" : "m3.example.net:27017",
  194. "ip" : "198.51.100.3",
  195. "health" : 1,
  196. "state" : 5,
  197. "stateStr" : "STARTUP2",
  198. "uptime" : 1316,
  199. "optime" : {
  200. "ts" : Timestamp(0, 0),
  201. "t" : NumberLong(-1)
  202. },
  203. "optimeDate" : ISODate("1970-01-01T00:00:00Z"),
  204. "syncingTo" : "m2.example.net:27017",
  205. "syncSourceHost" : "m2.example.net:27017",
  206. "syncSourceId" : 1,
  207. "infoMessage" : "",
  208. "configVersion" : 2,
  209. "self" : true,
  210. "lastHeartbeatMessage" : ""
  211. }
  212. ],
  213. "ok" : 1
  214. }

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 in rs.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 ofreplSetGetStatus.members[n].lastHeartbeat to find theoperational latency between this server and the other members of thereplica set.
  • replSetGetStatus.myState
  • An integer between 0 and 10 that represents the replicastate of the current member.
  • replSetGetStatus.term

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.

  • 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 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 "".

  • replSetGetStatus.syncSourceHost

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.

  • replSetGetStatus.syncSourceId

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.

  • 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 anew primary in an election.

  • replSetGetStatus.writeMajorityCount

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.

  • replSetGetStatus.optimes

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, the term 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.

  • replSetGetStatus.optimes.lastCommittedWallTime

  • The ISODate-formatted date string corresponding tolastCommittedOpTime.

The lastCommittedWallTime maynot accurately reflectlastCommittedOpTime if allmembers are not on MongoDB 4.2 or greater since thelastCommittedWallTimerequires communication with other members of the deployment.

New in version 4.2.

The readConcernMajorityWallTimemay not accurately reflectreadConcernMajorityOpTime ifall members are not on MongoDB 4.2 or greater since thereadConcernMajorityWallTimerequires 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.

  • replSetGetStatus.optimes.lastAppliedWallTime

  • The ISODate-formatted date string corresponding toappliedOpTime.

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.

  • replSetGetStatus.optimes.lastDurableWallTime

  • The ISODate-formatted date string corresponding todurableOpTime.

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 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.

  • 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 availableon the primary or a candidate for election. For a candidate, themetrics 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.termAtElection

New in version 4.2.1.

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 thismember, 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 calledfor 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 timeit called the election.

  • replSetGetStatus.electionCandidateMetrics.electionTimeoutMillis

New in version 4.2.1.

The replica set’s configuredelectionTimeoutMillis setting at the time ofthe election.

  • replSetGetStatus.electionCandidateMetrics.priorPrimaryMemberId

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.

  • replSetGetStatus.electionCandidateMetrics.numCatchUpOps

New in version 4.2.1.

The number of operations applied by the newly-elected primary asit 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 primarystarted (i.e. the date and time at which a new term entry waswritten 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 electionfor the replica set(i.e. the date and time at which the newterm oplog entry was majority committed).

  • replSetGetStatus.initialSyncStatus

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.

  • replSetGetStatus.initialSyncStatus.failedInitialSyncAttempts

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.

  • replSetGetStatus.initialSyncStatus.maxFailedInitialSyncAttempts

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.

  • 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 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.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 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.initialSyncStatus.initialSyncElapsedMillis

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.

  • replSetGetStatus.initialSyncStatus.initialSyncAttempts

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:

  1. {
  2. "durationMillis" : <duration in milliseconds>,
  3. "status" : <exit status>,
  4. "syncSource" : <source node from which this member performs initial sync>
  5. }

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.initialSyncStatus.fetchedMissingDocs

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.

  • replSetGetStatus.initialSyncStatus.appliedOps

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.

  • replSetGetStatus.initialSyncStatus.initialSyncOplogStart

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.

  • replSetGetStatus.initialSyncStatus.initialSyncOplogEnd

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.

  • 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 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.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 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.initialSyncStatus.databases.<dbname>

New in version 3.4.

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

  1. {
  2. "collections" : <number of collections to clone in the database>,
  3. "clonedCollections" : <number of collections cloned to date>,
  4. "start" : <start date and time for the database clone>,
  5. "end" : <end date and time for the database clone>,
  6. "elapsedMillis" : <duration of the database clone>,
  7. "<db>.<collection>" : {
  8. "documentsToCopy" : <number of documents to copy>,
  9. "documentsCopied" : <number of documents copied to date>,
  10. "indexes" : <number of indexes>,
  11. "fetchedBatches" : <number of batches of documents fetched to date>,
  12. "start" : <start date and time for the collection clone>,
  13. "end" : <end date and time for the collection clone>,
  14. "elapsedMillis" : <duration of the collection clone>,
  15. "receivedBatches" : <number of batches of documents received to date> // Added in 4.2
  16. }
  17. }

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.

    • replSetGetStatus.members[n].name

    • The name of the member.

    • replSetGetStatus.members[n].ip

    • The resolved IP address of the member. If themongod 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 currentmongod 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 and 10 that represents thereplica state of the member.

  • replSetGetStatus.members[n].stateStr

  • A string that describes state.

  • replSetGetStatus.members[n].uptime

  • 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:

  1. - <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).
  2. - <code>t</code>, the [<code>term</code>]($f569861c36592706.md#replSetGetStatus.term) in which the lastapplied operation was originally generated on the primary.
  • replSetGetStatus.members[n].optimeDurable

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:

  1. - <code>ts</code>, the [Timestamp]($a7c1e8e12192a4b0.md#document-bson-type-timestamp) ofthe operation.
  2. - <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 fromlastHeartbeat 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.

  • replSetGetStatus.members[n].optimeDurableDate

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.

  • replSetGetStatus.members[n].electionDate

  • For the current primary, an ISODate formatted date stringthat reflects the election date. SeeReplica Set High Availability for more information aboutelections.

  • replSetGetStatus.members[n].self

  • Indicates which replica set member processed thereplSetGetStatus command.

  • replSetGetStatus.members[n].lastHeartbeat

  • 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 the date 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, thelastHeartbeatMessage containsa string representation of that message.

  • replSetGetStatus.members[n].pingMs

  • 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.

  • 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 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 "".

  • replSetGetStatus.members[n].syncSourceHost

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.

  • replSetGetStatus.members[n].syncSourceId

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.

  • replSetGetStatus.members[n].configVersion

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.