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.

HTTP
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.

Shell
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

scope

string or null

No

View the records of the current identity or current workspace. Values: empty string, self, workspace.

non_user

boolean or null

No

Whether to filter non-user SQL.

start

string or null

No

Query start time, for example 2026-08-18T00:00:00Z. RFC 3339 time.

end

string or null

No

Query end time, for example, 2026-08-18T01:00:00Z. RFC 3339 time.

sql_source_type

array of string or null

No

Filter by SQL source.

status

string or null

No

Filter by execution status. Values: Running, Success, Failed.

user

array of string or null

No

Filter by execution user.

databases

array of string or null

No

Filter by database name.

statement

string or null

No

Matches SQL containing the specified text.

statement_id

string or null

No

Filter by statement ID.

transaction_id

string or null

No

Refine filtering by transaction ID.

session_id

string or null

No

Filter by session ID.

query_type

array of string or null

No

Filter by statement category: DDL, DML, DQL, DCL, TCL, or Other.

duration

integer or null

No

The minimum execution time, in nanoseconds.

selected_field

array of string or null

No

Specify the fields to be returned.

offset

integer or null

No

Offset from zero. The default value is 0. Not less than 0.

limit

integer or null

No

The maximum number of records returned at a time. Not less than 0.

order

string or null

No

Sort direction.

order_by

array of string or null

No

Sort field.

cu

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.

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:

Shell
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

JSON
{
  "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

data.total

integer

The total number of records matching the filter criteria.

data.offset

integer

The offset used in this response.

data.limit

integer

The upper limit of a single page actually used in this response.

data.query_list

array of object

SQL execution record list.

data.query_list[].statement_id

string

Statement ID.

data.query_list[].transaction_id

string

Transaction ID.

data.query_list[].session_id

string

Session ID.

data.query_list[].account

string

Account used for execution.

data.query_list[].user

string

Executing user.

data.query_list[].host

string

Execution host.

data.query_list[].database

string

The database used during execution.

data.query_list[].statement

string

SQL statement text.

data.query_list[].statement_tag

string

Statement label.

data.query_list[].statement_fingerprint

string

Sentence fingerprint.

data.query_list[].node_uuid

string

Execution node UUID.

data.query_list[].node_type

string

Execution node type.

data.query_list[].request_at

string

Start execution time.

data.query_list[].response_at

string

End execution time.

data.query_list[].duration

integer

Execution duration, in nanoseconds.

data.query_list[].status

string

execution status.

data.query_list[].error_code

string

error code.

data.query_list[].error

string

error message.

data.query_list[].exec_plan

string

Saved execution plan.

data.query_list[].rows_read

integer

Read the number of lines.

data.query_list[].bytes_scan

integer

Number of bytes to scan.

data.query_list[].statement_type

string

Statement type.

data.query_list[].query_type

string

Statement category.

data.query_list[].role_id

integer

Execution role ID.

data.query_list[].sql_source_type

string

SQL source type.

data.query_list[].result_count

integer

Number of result rows.

data.query_list[].cu

number

Capacity usage.

data.query_list[].connection_id

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

JSON
{
  "code": "ErrParamInvalid",
  "msg": "请求参数无效"
}

Field

Type

Description

code

string

error code.

msg

string

error message.

Last updated on