All Products
Search
Document Center

ApsaraDB for MongoDB:DescribeDBInstanceSwitchLog

Last Updated:Jan 21, 2026

Queries the primary/secondary switching logs of an ApsaraDB for MongoDB instance.

Operation description

Before you call this operation, make sure that the ApsaraDB for MongoDB instance meets the following requirements:

  • The instance is a replica set or sharded cluster instance.

  • The instance uses local physical disks to store data.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

dds:DescribeDBInstanceSwitchLog

list

*Instance

acs:dds:{#regionId}:{#accountId}:dbinstance/{#dbInstanceId}

None None

Request parameters

Parameter

Type

Required

Description

Example

StartTime

string

No

The beginning of the time range to query. Specify the time in the ISO 8601 standard in the yyyy-mm-ddThh:mmZ format. The time must be in UTC.

2023-05-27T02:46Z

EndTime

string

No

The end of the time range to query. Specify the time in the ISO 8601 standard in the yyyy-mm-ddThh:mmZ format. The time must be in UTC. The end time must be later than the start time.

2023-05-28T02:00Z

PageNumber

integer

No

The number of the page to return. The value must be an integer that is greater than 0 and less than or equal to the maximum value supported by the integer data type. Default value: 1.

1

PageSize

integer

No

The number of entries to return on each page. Valid values: 30, 50, and 100. Default value: 30.

30

DBInstanceId

string

No

The instance ID.

dds-uf68f1b5a57exxxx

Response elements

Element

Type

Description

Example

object

Schema of Response

RequestId

string

The request ID.

ECBCA991-XXXX-XXXX-834C-B3E8007F33AA

DBInstanceId

string

The instance ID.

dds-uf68f1b5a57exxxx

TotalCount

integer

The number of primary/secondary switching entries.

1

PageSize

integer

The number of entries returned on each page.

30

PageNumber

integer

The page number returned.

1

LogItems

array<object>

The primary/secondary switchover logs.

object

SwitchStatus

string

The switchover status. Valid values: 1 and 0. The value 1 indicates a successful primary/secondary switchover and the value 0 indicates a failed primary/secondary switchover.

1

SwitchTime

string

The point in time when a primary/secondary switchover was performed. The time follows the ISO 8601 standard in the yyyy-mm-ddThh:mm:ssZ format. The time is displayed in UTC.

2023-02-07T18:00:00Z

SwitchCode

string

The code that indicates the reason of a primary/secondary switchover. Valid values:

  • USER_CONSOLE_OPERATION: The switchover is manually performed.

  • OPERATION_AND_MAINTENANCE: Potential risks exist.

  • MACHINE_DOWNTIME: The host is offline.

  • PRIMARY_UNHEALTHY: An exception occurs on the primary node of the instance.

  • SECONDARY_UNHEALTHY: An exception occurs on the secondary node of the instance.

  • MULTIPLE_NODE_FAILURES: An exception occurs on multiple nodes of the instance.

USER_CONSOLE_OPERATION

NodeId

string

The ID of the replica set instance or the ID of the node on which a primary/secondary switchover is performed.

当实例为副本集实例:dds-uf68f1b5a57exxxx。 当实例为分片集实例:d-uf652b73f554xxxx

Examples

Success response

JSON format

{
  "RequestId": "ECBCA991-XXXX-XXXX-834C-B3E8007F33AA",
  "DBInstanceId": "dds-uf68f1b5a57exxxx",
  "TotalCount": 1,
  "PageSize": 30,
  "PageNumber": 1,
  "LogItems": [
    {
      "SwitchStatus": "1",
      "SwitchTime": "2023-02-07T18:00:00Z",
      "SwitchCode": "USER_CONSOLE_OPERATION",
      "NodeId": "当实例为副本集实例:dds-uf68f1b5a57exxxx。\n当实例为分片集实例:d-uf652b73f554xxxx"
    }
  ]
}

Error codes

HTTP status code

Error code

Error message

Description

400 InvalidParameterCombination The end time must be greater than the start time The start time must be earlier than the end time.

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.