Overview
You can call this API to query the list of suspicious SQL statements in a specified OceanBase Cloud instance during a specified period of time. This API is used for performance diagnostics. You can filter the SQL statements by database name, node IP address, SQL keyword, and custom filter conditions.
API details
Constraints
The caller must have an AccessKey for accessing multi-cloud APIs. For information about how to obtain the AccessKey ID and AccessKey secret, see Manage AccessKeys.
Request path
GET /api/v2/instances/{instanceId}/anomalySql
Request parameters
Path parameters
| Parameter | Type | Required | Description | Example value |
|---|---|---|---|---|
| instanceId | string | Yes | The ID of the OceanBase Cloud instance. | obcluster-***** |
Query parameters
| Parameter | Type | Required | Description | Example value |
|---|---|---|---|---|
| requestId | string | Yes | The request ID, which is used for tracing. | dc302d76-66b5-48d8-ab53-a035******** |
| startTime | string | Yes | The start time of the query (UTC format). | 2026-02-25 15:40:43+00:00 |
| endTime | string | Yes | The end time of the query (UTC format). | 2026-02-26 10:40:43+00:00 |
| dbName | string | No | The name of the database. This parameter is used to filter the SQL statements in the specified database. | test_db |
| nodeIp | string | No | The IP address of the node. This parameter is used to filter the SQL statements in the specified node. | 192.168.1.1 |
| searchKeyWord | string | No | The SQL keyword. This parameter is used to perform a fuzzy match on the SQL text. | update |
| sqlTextLength | integer | No | The maximum length of the returned SQL text. The part exceeding this length will be truncated. | 65535 |
| filterCondition | string | No | The custom filter condition. Fields are referenced by using the @ symbol. For example: @avgCpuTime > 20 and @executions > 100. |
@avgCpuTime > 20 and @executions > 100 |
| mergeDynamicSql | boolean | No | Specifies whether to merge dynamic SQL statements. | true |
| dynamicSql | boolean | No | Specifies whether to query dynamic SQL statements. | false |
Response parameters
| Parameter | Type | Description |
|---|---|---|
| success | boolean | Indicates whether the request was successful. |
| data | array | The list of suspicious SQL statements. |
| message | string | The returned message. |
| server | string | The address of the server that processed the request. |
Examples
Request example
curl -X GET \
'https://api-cloud.oceanbase.com/api/v2/instances/{instanceId}/anomalySql?requestId={requestId}&startTime=2026-02-25%2015:40:43%2B00:00&endTime=2026-02-26%2010:40:43%2B00:00&dbName=test_db&nodeIp=192.168.1.1&searchKeyWord=update&sqlTextLength=65535&filterCondition=@avgCpuTime%20%3E%2020%20and%20@executions%20%3E%20100&mergeDynamicSql=true&dynamicSql=false' \
-H 'Content-Type: application/json' \
-u '<Your ak:sk>'
Response example
{
"success": true,
"data": [
{
"sqlId": "xxxxxx",
"sqlText": "SELECT * FROM users WHERE id = ?",
"dbName": "test_db",
"nodeIp": "192.168.1.1",
"avgCpuTime": 150.5,
"executions": 1000,
"lastExecutedTime": "2026-02-26 09:30:00"
}
],
"message": "success",
"server": "xxx.xxx.x.xxx:xxxx"
}
