Updated on 2022-12-12 GMT+08:00

Querying Sessions of an Instance Node

API Description

This API is used to query sessions of instance nodes.

Restrictions

Community Edition 3.4 and 4.0 instances are supported.

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

Name

Type

IN

Mandatory

Description

x-auth-token

string

header

Yes

User token

project_id

string

path

Yes

The project ID of a tenant in a region. To obtain the project ID, see Obtaining a Project ID.

node_id

string

path

Yes

The node ID.

  • Select the mongos node in a cluster instance.
  • Select the primary or secondary node in a replica set instance.
Table 2 Query parameters

Parameter

Type

Mandatory

Description

offset

Integer

No

The index position. If offset is set to N, the resource 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 cannot be a negative number.

limit

Integer

No

The number of records to be queried. The value range is [1, 20]. The default value is 10, indicating that 10 records are returned.

plan_summary

String

No

The description of an execution plan. 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

type

String

No

The operation type. 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.

namespace

String

No

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

cost_time

Integer

No

The duration. The unit is us. 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.

Response Parameters

  • Parameter description
    Table 3 Response body parameters

    Parameter

    Type

    Mandatory

    Description

    total_count

    Integer

    Yes

    The total number of records.

    sessions

    Array of objects

    Yes

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

    Table 4 Data structure description of the session field

    Parameter

    Type

    Description

    id

    String

    The session ID.

    active

    Boolean

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

    operation

    String

    Operation.

    type

    String

    Operation type.

    cost_time

    String

    Duration. The unit is us.

    plan_summary

    String

    The description of an execution plan.

    host

    String

    Host.

    client

    String

    Client address.

    description

    String

    Indicates the connection description.

    namespace

    String

    Namespace.

Response example

{ 
  "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" 
  } ] 
}

Status Code

For more information, see Status Code.

Error Code

For more information, see Error Code.