Overview
You can call this API to query SQL audit data.
API details
Constraints
The caller must have an AccessKey for accessing the multi-cloud API. For information about how to obtain the AccessKey ID and AccessKey Secret, see Manage AccessKeys.
Request path
GET /api/v2/instances/{instanceId}/tenants/{tenantId}/sqlaudit/data
Request parameters
Path
Name |
Type |
Required |
Description |
Example value |
|---|---|---|---|---|
| instanceId | String | Yes | OceanBase Cloud instance ID. | ob317v4uif**** |
| tenantId | String | Yes | Tenant ID. | t4louaeei**** |
Query
Name |
Type |
Required |
Description |
Example value |
|---|---|---|---|---|
| startTime | String | Yes | Interval start time. | 2025-01-01T00:00:00Z |
| endTime | String | Yes | Interval end time. | 2025-01-02T00:00:00Z |
| clientIp | String | No | JSON-encoded array of client IP addresses. Example: ["xx.xxx.xx.xxx"]. |
["xx.xxx.xx.xxx"] |
| dbName | String | No | JSON-encoded array of database names. Example: ["default_database"]. |
["default_database"] |
| executeTimeMin | Integer | No | Minimum execution time in milliseconds. | 10 |
| executeTimeMax | Integer | No | Maximum execution time in milliseconds. | 1000 |
| nodeIp | String | No | JSON-encoded array of execution node IP addresses. Example: ["i-bp18l4****str4uk03"]. |
["i-bp18l4****str4uk03"] |
| operatorType | String | No | JSON-encoded array of SQL statement types. Example: ["SELECT", "CREATE"]. |
["SELECT", "CREATE"] |
| scanRowsMin | Integer | No | Minimum number of scanned rows. | 0 |
| scanRowsMax | Integer | No | Maximum number of scanned rows. | 10000 |
| userName | String | No | JSON-encoded array of usernames. Example: ["doc_test"]. |
["doc_test"] |
| searchKeyWord | String | No | JSON-encoded array of query keywords. Example: ["keyword1", "keyword2"]. Effective only when specified together with searchKeyWordMethod. |
["keyword1", "keyword2"] |
| searchKeyWordMethod | String | No | Relationship between query keywords. Valid values: and and or. Effective only when specified together with searchKeyWord. |
and |
| sortField | String | No | Sort field. | elapsedTime |
| sortType | String | No | Sort type. | desc |
| pageNumber | Integer | No | Page number. Default: 1. | 1 |
| pageSize | Integer | No | Number of records per page. Default: 10. | 10 |
| openRequest | unknown | Yes | Open request parameter. | - |
Response parameters
Name |
Type |
Description |
Example value |
|---|---|---|---|
| success | Boolean | Whether the request was successful. | true |
| errorCode | String | Error code. | INVALID_PARAMETER |
| errorMessage | String | Error message. | Invalid parameter |
| data | Object | Business data (object). | N/A |
| cost | Number | Time consumed. | 1.0 |
| server | String | Server address, typically the IP address of an OBServer node. | 10.0.0.10 |
| requestId | String | Request ID. | d04eabba**** |
| totalCount | Number | Total number of records. | 100.0 |
| extra | Object | Extended information. | {} |
data object fields
Name |
Type |
Description |
Example value |
|---|---|---|---|
| sqlAuditDTOList | Array | SQL audit record list. | [{'id': 'resource-123456'}] |
| totalCount | Integer | Total number of records. | 100 |
data.sqlAuditDTOList[] object fields
Name |
Type |
Description |
Example value |
|---|---|---|---|
| key | Integer | Key. | 1 |
| querySQL | String | SQL query. | SELECT * FROM users WHERE id = 1 |
| sqlID | String | Unique SQL statement identifier. | sql_1234**** |
| databaseName | String | Database name. | test_db |
| userName | String | Username. | root |
| clientIp | String | Client IP parameter. | successful |
| userClientIp | String | User client IP address. | admin |
| operatorType | String | Operation type. | NORMAL |
| elapsedTime | Number | SQL execution time. | 12.5 |
| scanRows | Integer | Number of rows scanned by the SQL statement. | 1 |
| affectedRows | Integer | Number of rows affected by the SQL statement. | 1 |
| requestTime | String | Request time. | 2026-02-25 15:40:43+00:00 |
| requestTimestamp | Integer | Request timestamp. | 1 |
| isSuccess | Integer | Whether the operation was successful. | 1 |
| retCode | Integer | Return code. | 0 |
Examples
Request example
curl --digest -u '<Your AccessKey ID:AccessKey Secret>' \
-X GET \
'https://api-cloud.oceanbase.com/api/v2/instances/{instanceId}/tenants/{tenantId}/sqlaudit/data?openRequest={openRequest}' \
-G \
--data-urlencode 'searchKeyWord=["keyword1","keyword2"]' \
-d 'searchKeyWordMethod=and' \
-d 'startTime={startTime}' \
-d 'endTime={endTime}' \
-d 'pageNumber={pageNumber}' \
-d 'pageSize={pageSize}'
Response example
JSON format
{
"success": true,
"errorCode": "INVALID_PARAMETER",
"errorMessage": "Invalid parameter",
"data": {
"sqlAuditDTOList": [
{
"key": 1,
"querySQL": "SELECT * FROM users WHERE id = 1",
"sqlID": "sql_1234****",
"databaseName": "test_db",
"userName": "root",
"clientIp": "successful",
"userClientIp": "admin",
"operatorType": "NORMAL",
"elapsedTime": 12.5,
"scanRows": 1,
"affectedRows": 1,
"requestTime": "2026-02-25 15:40:43+00:00",
"requestTimestamp": 1,
"isSuccess": 1,
"retCode": 0
}
],
"totalCount": 100
},
"cost": 1.0,
"server": "xxx.xxx.x.xxx:xxx",
"requestId": "d04eabba****",
"totalCount": 100.0,
"extra": "{}"
}
