For AI agents: a documentation index is available at https://www.mongodb.com/ko-kr/docs/llms.txt — markdown versions of all pages are available by appending .md to any URL path.

Read Replication Health Through the Get Host APIs

You can use the Ops Manager API to determine whether a replica set member fell too far behind to catch up. You can also read the member's last replication error.

Ops Manager adds two fields to the host document, tooStale and lastReplError, and returns them from new v2.0 versions of the three Get Host endpoints. The v1.0 endpoints are unchanged and never return the new fields.

To call these endpoints, you must have the Project Read Only role.

Item
Detail

New endpoints

v2.0 versions of Get One Host by ID, Get One Host by Hostname and Port, and Get All Hosts. Same paths as v1.0 under /api/public/v2.0.

New fields

tooStale and lastReplError on the host document.

Existing endpoints

v1.0 is unchanged, including the hosts endpoints in the Admin API.

  • Your deployment must run Ops Manager 8.0.28 or 9.0.2 or later.

  • Monitoring must be enabled for the project. If monitoring is disabled, Ops Manager omits the new fields.

  • Change the base path of your requests from /api/public/v1.0 to /api/public/v2.0. The rest of each request is unchanged.

1

Use v2.0 Get All Hosts to list hosts, or use the hostname:port you already know.

2
curl --user "{PUBLIC-KEY}:{PRIVATE-KEY}" --digest \ --header "Accept: application/json" \ --include \ --request GET "https://<OpsManagerHost>:<Port>/api/public/v2.0/groups/{GROUP-ID}/hosts/byName/{HOSTNAME-PORT}?pretty=true"
3
{ "hostname": "node1.example.com", "port": 27017, "replicaSetName": "rs0", "replicaStateName": "RECOVERING", "tooStale": true, "lastReplError": "error RS102 too stale to catch up"}

The document is trimmed for brevity. Ops Manager returns the complete host document.

Name
Type
Description

tooStale

boolean

The member fell behind the oplog window and could not catch up from the replica set. The member requires an initial sync.

lastReplError

string

The member's last replication error, from rs.status().

The following table describes how Ops Manager populates the new fields in specific scenarios.

Scenario
Behavior

Host is a healthy replica set member

tooStale is false. lastReplError is omitted.

Member is behind the oplog window

tooStale is true. lastReplError carries the mongod's message.

Host isn't a replica set member

Both fields are omitted.

Request uses a v1.0 endpoint

Both fields are omitted.

Get All Hosts

Each host reports its own member's values, not the replica set's.

Both fields describe the single host in the response, not the whole replica set.

The following table describes common errors and symptoms when you use the v2.0 Get Host endpoints.

Symptom
Likely Cause
Resolution

404 from a v2.0 endpoint

The base path is /api/public/v1.0, or the host isn't in the project.

Use /api/public/v2.0 and confirm the host with v2.0 Get All Hosts.

tooStale and lastReplError are missing

The host isn't a replica set member, monitoring is disabled, or you called a v1.0 endpoint.

Confirm the host belongs to a replica set, monitoring is enabled, and the path uses v2.0.

lastReplError is missing but tooStale is present

The member reports no replication error.

No action needed.

404 HOST_NOT_FOUND

HOST-ID or HOSTNAME-PORT doesn't match a host in the project.

Confirm the value with v2.0 Get All Hosts.

To read replication health programmatically, see Get Hosts with Replication Health.