Help Center/ Database Security Service/ API Reference/ API/ Data Reports/ Querying Database User Session Distribution
Updated on 2025-09-10 GMT+08:00

Querying Database User Session Distribution

Function

This API is used to query the user session distribution of a database.

URI

POST /v1/{project_id}/audit/{instance_id}/statistics/session/db-account

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Definition:

Project ID. You can obtain the value by calling the IAM API for querying the project list of a specified IAM user.

Constraints

N/A

Range:

The value is subject to the return value of the IAM service interface. The value contains 32 to 64 characters.

Default Value:

N/A

instance_id

Yes

String

Definition:

Instance ID. The value can be obtained from the ID field of the API for querying the instance list.

Constraints

N/A

Range:

The value is subject to the value of the API for querying the instance list. The value contains 32 to 64 characters.

Default Value:

N/A

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

Definition:

User token. You can obtain the token by calling the IAM API used to query the user token. The token is the value of X-Subject-Token in the response header.

Constraints

N/A

Range:

The value is subject to the user token query interface of the IAM service.

Default Value:

N/A

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

db_id

No

Array of strings

Database ID.

time

Yes

Duration object

Query time range. time_range takes precedence over start_time/end_time.

Table 4 Duration

Parameter

Mandatory

Type

Description

end_time

No

String

End time

start_time

No

String

Start time

time_range

No

String

time_range

  • HALF_HOUR: half an hour

  • HOUR: 1 hour

  • THREE_HOUR: 3 hours

  • TWELVE_HOUR: 12 hours

  • DAY: 1 day

  • WEEK: 1 week

  • MONTH: 1 month

Response Parameters

Status code: 200

Table 5 Response body parameters

Parameter

Type

Description

[items]

Array of ReportAccountSessionNew objects

Table 6 ReportAccountSessionNew

Parameter

Type

Description

db_id

String

The database record ID.

db_ip

String

Database IP address

db_name

String

Database name

db_user

String

Database User

session_num

Long

Number of sessions

Status code: 400

Table 7 Response body parameters

Parameter

Type

Description

details

Array of DbssErrorDetail objects

PDP5 authentication exception information

encoded_authorization_message

String

PDP5 authentication exception information

error_code

String

Error Codes

error_msg

String

Error message.

Table 8 DbssErrorDetail

Parameter

Type

Description

error_code

String

Error Codes

error_msg

String

PDP5 error information

Status code: 401

Table 9 Response body parameters

Parameter

Type

Description

details

Array of DbssErrorDetail objects

PDP5 authentication exception information

encoded_authorization_message

String

PDP5 authentication exception information

error_code

String

Error Codes

error_msg

String

Error message.

Table 10 DbssErrorDetail

Parameter

Type

Description

error_code

String

Error Codes

error_msg

String

PDP5 error information

Status code: 403

Table 11 Response body parameters

Parameter

Type

Description

details

Array of DbssErrorDetail objects

PDP5 authentication exception information

encoded_authorization_message

String

PDP5 authentication exception information

error_code

String

Error Codes

error_msg

String

Error message.

Table 12 DbssErrorDetail

Parameter

Type

Description

error_code

String

Error Codes

error_msg

String

PDP5 error information

Status code: 500

Table 13 Response body parameters

Parameter

Type

Description

details

Array of DbssErrorDetail objects

PDP5 authentication exception information

encoded_authorization_message

String

PDP5 authentication exception information

error_code

String

Error Codes

error_msg

String

Error message.

Table 14 DbssErrorDetail

Parameter

Type

Description

error_code

String

Error Codes

error_msg

String

PDP5 error information

Example Requests

/v1/{project_id}/audit/{instance_id}/statistics/session/db-account

{
  "db_id" : [ "nhlzy5gBs27Fw8ND_w_P" ],
  "time" : {
    "end_time" : "2025-08-10 09:34:10",
    "start_time" : "2025-08-08 09:34:10",
    "time_range" : "HALF_HOUR"
  }
}

Example Responses

Status code: 200

OK

[ {
  "db_id" : "nhlzy5gBs27Fw8ND_w_P",
  "db_user" : "root",
  "session_num" : 33,
  "db_name" : "rds-ce88",
  "db_ip" : "10.0.0.3"
} ]

Status Codes

Status Code

Description

200

OK

400

Invalid request parameter.

401

Authorization failed.

403

Unauthorized

500

Server error.

Error Codes

See Error Codes.