List SQL execution records¶
View SQL execution records in the current workspace by condition, which can be used to troubleshoot execution failures, slow execution, or SQL in a specific database. By default, only records executed by the current identity are viewed. When you have the corresponding permissions, you can view records in the workspace scope.
POST $CLOUDSIGMA_API_BASE/query/history
Before you call¶
Configure the CloudSigma regional endpoint and authentication before calling. The endpoint, credentials, workspace, and resource IDs must belong to the same region. Prepare personal access token and current workspace ID with current workspace access rights.
Request body¶
Replace $CLOUDSIGMA_API_KEY, $WORKSPACE_ID in the example with actual values.
curl -X POST "$CLOUDSIGMA_API_BASE/query/history" \
-H "X-API-Key: $CLOUDSIGMA_API_KEY" \
-H "X-Workspace-ID: $WORKSPACE_ID" \
-H 'Content-Type: application/json' \
-d '{
"status": "Success",
"databases": [
"analytics"
],
"start": "2026-08-18T00:00:00Z",
"end": "2026-08-18T01:00:00Z",
"limit": 20,
"order_by": [
"request_at"
],
"order": "DESC"
}'
Field |
Type |
Required |
Description |
|---|---|---|---|
|
string or null |
No |
View the records of the current identity or current workspace. Values: empty string, |
|
boolean or null |
No |
Whether to filter non-user SQL. |
|
string or null |
No |
Query start time, for example 2026-08-18T00:00:00Z. RFC 3339 time. |
|
string or null |
No |
Query end time, for example, 2026-08-18T01:00:00Z. RFC 3339 time. |
|
array of string or null |
No |
Filter by SQL source. |
|
string or null |
No |
Filter by execution status. Values: |
|
array of string or null |
No |
Filter by execution user. |
|
array of string or null |
No |
Filter by database name. |
|
string or null |
No |
Matches SQL containing the specified text. |
|
string or null |
No |
Filter by statement ID. |
|
string or null |
No |
Refine filtering by transaction ID. |
|
string or null |
No |
Filter by session ID. |
|
array of string or null |
No |
Filter by statement category: DDL, DML, DQL, DCL, TCL, or Other. |
|
integer or null |
No |
The minimum execution time, in nanoseconds. |
|
array of string or null |
No |
Specify the fields to be returned. |
|
integer or null |
No |
Offset from zero. The default value is 0. Not less than 0. |
|
integer or null |
No |
The maximum number of records returned at a time. Not less than 0. |
|
string or null |
No |
Sort direction. |
|
array of string or null |
No |
Sort field. |
|
integer or null |
No |
Capacity usage threshold. |
non_user is an optional Boolean value, and sql_source_type has a higher priority than this field. When non_user is omitted or null is filled in, no additional source filtering conditions are added.
selected_field supports the 28 fields listed in the query_list table below. The response always contains request_at. When only request_at is selected, the default field set is returned.
A normal field with a value of 0 may not be returned, the value 0 in a JSON metric may still be returned.
When cu is greater than 0, only records whose capacity usage exceeds this value are queried. Turn off filtering when filling in 0. This filtering may fail when there is no cu column in the deployment.
When the time range is omitted, the deployment’s configured default query window is used. The window is not fixed at 5 minutes.
View range
scope value |
Viewable records |
Permission conditions. |
|---|---|---|
self |
A record of current identity. |
Default scope. |
workspace |
Workspace scope records. |
Workspace audit read permission is required. |
Query time and ID
The time must be filled in with the complete date, time and time zone. When the start and end times are not filled in, the records are queried according to the default lookback window of the deployment configuration. You can fill in only one of the times as the query boundary.
Exact match when entering full statement ID or session ID. When a legal fragment is entered, records containing that fragment are matched. ID fragments can only contain letters, numbers, and hyphens.
Select return content
When no return fields are specified, the service returns default fields. Whether specified or not, the result will include the request time. When no SQL source is specified, the service returns only user SQL and external SQL. When the number of items per page is omitted or 0, 10 is used, and the maximum is 1000. When the capacity usage threshold is greater than 0, only records with capacity usage greater than the threshold will be returned. This filter is not enabled when 0 is entered.
Sortable fields
When order_by is omitted, the values are sorted in descending order by request time. When order is DESC, the order is descending, and other values are processed in ascending order.
Field |
meaning. |
|---|---|
request_at |
Request time. |
response_at |
response time. |
duration |
Execution duration. |
rows_read |
Read the number of lines. |
bytes_scan |
Number of bytes to scan. |
cu |
Capacity usage. |
Read next page
When reading the next page, increase offset to the number of items returned this time and retain the original filtering conditions. For example, when the first page is offset=0, limit=20, the next page request is:
curl -X POST "$CLOUDSIGMA_API_BASE/query/history" \
-H "X-API-Key: $CLOUDSIGMA_API_KEY" \
-H "X-Workspace-ID: $WORKSPACE_ID" \
-H 'Content-Type: application/json' \
-d '{
"status": "Success",
"databases": ["analytics"],
"start": "2026-08-18T00:00:00Z",
"end": "2026-08-18T01:00:00Z",
"offset": 20,
"limit": 20,
"order_by": ["request_at"],
"order": "DESC"
}'
Stop turning pages when the cumulative number of reads reaches the total, or when there is no record this time.
Successful response¶
{
"code": "OK",
"msg": "OK",
"data": {
"total": 1,
"offset": 0,
"limit": 20,
"query_list": [
{
"statement_id": "5c6f22fb-ef0e-4f46-b06f-c31e1a7afb48",
"database": "analytics",
"statement": "SELECT * FROM orders",
"request_at": "2026-08-18T00:30:00Z",
"response_at": "2026-08-18T00:30:01Z",
"duration": 1000,
"status": "Success",
"query_type": "DQL",
"result_count": 10
}
]
}
}
Field |
Type |
Description |
|---|---|---|
|
integer |
The total number of records matching the filter criteria. |
|
integer |
The offset used in this response. |
|
integer |
The upper limit of a single page actually used in this response. |
|
array of object |
SQL execution record list. |
|
string |
Statement ID. |
|
string |
Transaction ID. |
|
string |
Session ID. |
|
string |
Account used for execution. |
|
string |
Executing user. |
|
string |
Execution host. |
|
string |
The database used during execution. |
|
string |
SQL statement text. |
|
string |
Statement label. |
|
string |
Sentence fingerprint. |
|
string |
Execution node UUID. |
|
string |
Execution node type. |
|
string |
Start execution time. |
|
string |
End execution time. |
|
integer |
Execution duration, in nanoseconds. |
|
string |
execution status. |
|
string |
error code. |
|
string |
error message. |
|
string |
Saved execution plan. |
|
integer |
Read the number of lines. |
|
integer |
Number of bytes to scan. |
|
string |
Statement type. |
|
string |
Statement category. |
|
integer |
Execution role ID. |
|
string |
SQL source type. |
|
integer |
Number of result rows. |
|
number |
Capacity usage. |
|
integer |
Database connection ID. |
Select SQL execution record
To continue troubleshooting, select a SQL execution record in the results and note its statement ID and execution time. You can then Query SQL execution details or Query SQL execution plan.
If you need to re-execute SQL, first obtain the SQL text from the selected record. Confirm the permissions of the target database and the current identity, and then use Execute SQL.
Error response¶
{
"code": "ErrParamInvalid",
"msg": "请求参数无效"
}
Field |
Type |
Description |
|---|---|---|
code |
string |
error code. |
msg |
string |
error message. |