Updated on 2025-07-04 GMT+08:00

Querying Sessions of an Instance Node

API Description

This API is used to query sessions of instance nodes.

Restrictions

This function is available for DB instances of Community Edition 3.4 or later.

URI

  • URI format

    GET https://{Endpoint}/v3/{project_id}/nodes/{node_id}/sessions

  • URI example

    https://ap-southeast-1.myhuaweicloud.com/v3/054e292c9880d4992f02c0196d3ea468/nodes/520c58ba00a3497e97ce0b9604874dd6no02/sessions

Request Parameters

Parameter description

Table 1 Request parameters

Parameter

Type

IN

Mandatory

Description

X-Auth-Token

string

header

Yes

Definition

User token obtained from IAM. For details, see Authentication.

Constraints

N/A

Range

N/A

Default Value

N/A

project_id

string

path

Yes

Definition

Project ID of a tenant in a region. Obtain the project ID by following the instructions in Obtaining a Project ID.

Constraints

N/A

Range

N/A

Default Value

N/A

node_id

string

path

Yes

Definition

Node ID.

Constraints

  • For a cluster instance, you can select any mongos, shard, or config node.
  • For a replica set instance, you can select the primary or secondary node.

Range

N/A

Default Value

N/A

Table 2 Query parameters

Parameter

Type

Mandatory

Description

offset

Integer

No

Definition

Index offset.

Constraints

If offset is set to N, the query starts from the N+1 piece of data. The value is 0 by default, indicating that the query starts from the first piece of data. The value must be a number but cannot be a negative number.

Range

N/A

Default Value

0

limit

Integer

No

Definition

Number of records to be queried.

Constraints

N/A

Range

[1, 100]

Default Value

10 (indicating that 10 records are returned)

plan_summary

String

No

Definition

The description of an execution plan.

Constraints

N/A

Range

If this parameter is left empty, sessions in which plan_summary is empty are queried. You can also specify an execution plan, for example, COLLSCAN IXSCAN FETCH SORT LIMIT SKIP COUNT COUNT_SCAN TEXT PROJECTION.

Default Value

N/A

type

String

No

Definition

Operation type.

Constraints

N/A

Range

If this parameter is left empty, sessions in which type is empty are queried. You can also specify an operation type, for example, none update insert query command getmore remove killcursors.

Default Value

N/A

namespace

String

No

Definition

Namespace.

Constraints

If this parameter is left blank, the sessions in which namespace is empty are queried. You can also specify the value based on the service requirements.

Range

N/A

Default Value

N/A

cost_time

Integer

No

Definition

Running time, in μs.

Constraints

If this parameter is left empty, the sessions in which cost_time is empty are queried. You can also set this parameter based on the service requirements, indicating that the sessions in which the value of cost_time exceeds the specified value are queried.

Range

N/A

Default Value

N/A

Response Parameters

  • Parameter description
    Table 3 Response body parameters

    Parameter

    Type

    Mandatory

    Description

    total_count

    Integer

    Yes

    Definition

    The total number of records.

    Range

    N/A

    sessions

    Array of objects

    Yes

    Definition

    The detailed information. For details, see the QuerySessionResponse table.

    Range

    N/A

    Table 4 Data structure description of the session field

    Parameter

    Type

    Description

    id

    String

    Definition

    The session ID.

    Range

    N/A

    active

    Boolean

    Definition

    Whether the current session is active. If the value is "true", the session is active. If the value is "false", the session is inactive.

    Range

    N/A

    operation

    String

    Definition

    Operation.

    Range

    N/A

    type

    String

    Definition

    Operation type.

    Range

    N/A

    cost_time

    String

    Definition

    Running time, in μs.

    Range

    N/A

    plan_summary

    String

    Definition

    The description of an execution plan.

    Range

    N/A

    host

    String

    Definition

    Host.

    Range

    N/A

    client

    String

    Definition

    Client address.

    Range

    N/A

    description

    String

    Definition

    Indicates the connection description.

    Range

    N/A

    namespace

    String

    Definition

    Namespace.

    Range

    N/A

    db

    String

    Definition

    Name of the database that is being operated.

    Range

    N/A

    user

    String

    Definition

    Username.

    Range

    N/A

Example Response

{ 
  "total_count" : 1, 
  "sessions" : [ { 
    "id" : "shard_1:7201646", 
    "active" : true, 
    "operation" : "{\"getMore\":4.9473050217983027E18,\"collection\":\"$cmd.aggregate\",\"batchSize\":101.0,\"lsid\":{\"id\":{\"$binary\":{\"base64\":\"9FhcBFVeTzafCH8BUZrLjQ\\=\\=\",\"subType\":\"03\"}},\"uid\":{\"$binary\":{\"base64\":\"O0CMtIVItQN4IsEOsJdrPL8s7jv5xwh5a/A5Qfvs2A8\\=\",\"subType\":\"00\"}}},\"$clusterTime\":{\"clusterTime\":{\"$timestamp\":{\"t\":1.614047961E9,\"i\":1.0}},\"signature\":{\"hash\":{\"$binary\":{\"base64\":\"HxUWu68VyfvQFivWjHQDdJj/3YQ\\=\",\"subType\":\"00\"}},\"keyId\":6.9312672235666801E18}},\"$client\":{\"driver\":{\"name\":\"PyMongo\",\"version\":\"3.6.1\"},\"os\":{\"type\":\"Linux\",\"name\":\"Linux\",\"architecture\":\"x86_64\",\"version\":\"4.18.0-147.5.1.0.h269.eulerosv2r9.x86_64\"},\"platform\":\"CPython 3.7.4.final.0\",\"mongos\":{\"host\":\"host-172-16-61-110:8635\",\"client\":\"127.0.0.1:33420\",\"version\":\"4.0.3\"}},\"$configServerState\":{\"opTime\":{\"ts\":{\"$timestamp\":{\"t\":1.614047961E9,\"i\":1.0}},\"t\":2.0}},\"$db\":\"admin\"}", 
    "type" : "getmore", 
    "cost_time" : "25", 
    "plan_summary" : "COLLSCAN", 
    "host" : "host-172-16-27-182:8635", 
    "client" : "172.16.41.233:50700", 
    "description" : "conn20", 
    "namespace" : "admin.$cmd.aggregate",
    "db" : "admin", 
    "user" : "root" 
  } ] 
}

SDK

Click Document Database Service DDS SDK to download the SDK or view the SDK document. To learn how to install and authenticate an SDK, read the Usage section.

Status Code

For more information, see Status Code.

Error Code

For more information, see Error Code.