You can call the DescribeSqlLogRecords operation to query the details of logs in DAS Enterprise Edition.
Operation description
Before you call this operation, note the following:
Use the latest version of the Alibaba Cloud software development kit (SDK) or the DAS SDK.
When you use an SDK to call the DAS service, set the region to cn-shanghai.
Try it now
Test
RAM authorization
|
Action |
Access level |
Resource type |
Condition key |
Dependent action |
|
hdm:DescribeSqlLogRecords |
list |
*All Resource
|
None | None |
Request parameters
|
Parameter |
Type |
Required |
Description |
Example |
| InstanceId |
string |
Yes |
The ID of the database instance. |
pc-2ze8g2am97624**** |
| NodeId |
string |
No |
The node ID.
|
pi-uf6k5f6g3912i**** |
| Role |
string |
No |
The role of the node in the PolarDB-X 2.0 database instance.
|
polarx_cn |
| Filters |
array<object> |
No |
The filter conditions. |
|
|
object |
No |
The filter condition. |
||
| Key |
string |
No |
The filter parameter. Note
For information about the supported filter parameters and their valid values, see the Additional information about request parameters section in this topic. |
keyWords |
| Value |
string |
No |
The value of the filter parameter. |
select |
| StartTime |
integer |
No |
The beginning of the time range to query. Specify the time as a UNIX timestamp. Unit: milliseconds. |
1596177993000 |
| EndTime |
integer |
No |
The end of the time range to query. Specify the time as a UNIX timestamp. Unit: milliseconds. |
1608888296000 |
| PageNo |
integer |
No |
The page number. Pages start from page 1. Default value: 1. |
1 |
| PageSize |
integer |
No |
The number of entries to return on each page. Maximum value: 100. Default value: 10. |
10 |
The following parameters are supported for Key:
KeyWords: The keywords for the query. Separate multiple keywords with spaces.
LogicalOperator: The logical operator that connects the keywords. Valid values: "and" and "or".
AccountName: The database username. You can specify up to five usernames, separated by commas (,).
dbName: The database name. You can specify up to five database names, separated by commas (,).
HostAddress: The client IP address. You can specify up to five IP addresses, separated by commas (,).
MaxConsume: The maximum execution duration. Unit: microseconds (us).
MinConsume: The minimum execution duration. Unit: microseconds (us).
MaxScanRows: The maximum number of scanned rows.
MinScanRows: The minimum number of scanned rows.
SqlType: The SQL type. Valid values: select, update, insert, and delete.
State: The execution result. Valid values: 0 (successful) and 1 (failed).
ThreadId: The thread ID.
SortKey: The column to sort by. Valid values: ScanRows (number of scanned rows), UpdateRows (number of updated rows), Consume (execution duration), ExecuteTime (running time), ReturnRows (number of returned rows), LockTime (lock wait time), Frows (number of rows pulled by a compute node of a PolarDB-X 2.0 instance), Scnt (number of requests from a compute node to a data node of a PolarDB-X 2.0 instance), CpuTime (CPU execution time), and PhysicalRead (physical reads).
SortMethod: The sorting method. Valid values: DESC (descending) and ASC (ascending). Default value: DESC.
TraceId: The trace ID of the PolarDB-X 2.0 instance.
MinRows: The minimum number of updated rows.
MaxRows: The maximum number of updated rows.
MinScnt: The minimum number of requests from a compute node (CN) to a data node (DN) of a PolarDB-X 2.0 instance.
MaxScnt: The maximum number of requests from a CN to a DN of a PolarDB-X 2.0 instance.
TrxId: The transaction ID.
Fail: The error code.
SqlId: The SQL ID.
JobId: The ID of the asynchronous task. You can use this ID to query the result.
Response elements
|
Element |
Type |
Description |
Example |
|
object |
|||
| Code |
string |
The HTTP status code returned. |
200 |
| Message |
string |
The message returned for the request. Note
If the request is successful, Successful is returned. If the request fails, an error message such as an error code is returned. |
Successful |
| RequestId |
string |
The request ID. |
F43E7FB3-CE67-5FFD-A59C-EFD278BCD7BE |
| Success |
string |
Indicates whether the request was successful. Valid values:
|
true |
| Data |
object |
The returned data. |
|
| StartTime |
integer |
The beginning of the time range to query. The time is a UNIX timestamp. Unit: milliseconds. |
1596177993000 |
| EndTime |
integer |
The end of the time range to query. The time is a UNIX timestamp. Unit: milliseconds. |
1608888296000 |
| TotalRecords |
integer |
The total number of entries. |
1 |
| Items |
object |
The data returned. |
|
| SQLLogRecord |
array<object> |
The SQL log data. |
|
|
object |
The SQL log data. |
||
| Ext |
string |
The extended information. This parameter is reserved. |
None |
| ExecuteTime |
string |
The execution time. The time is in Coordinated Universal Time (UTC) and the format is |
2023-12-07T02:15:32Z |
| OriginTime |
integer |
The execution timestamp. This value is a UNIX timestamp. Unit: milliseconds. |
1701886532000 |
| HostAddress |
string |
The client IP address. |
11.197.XX.XX |
| UpdateRows |
integer |
The number of updated rows. |
0 |
| LogicRead |
integer |
The number of logical reads. |
0 |
| SqlText |
string |
The SQL statement. |
select resource_id as cluster_id, tpl_name \n\tfrom dbfree_alert_resource_tpl_ref\n\twhere user_id=? and type='cluster' group by resource_id, tpl_name |
| LockTime |
integer |
The lock wait time. Unit: milliseconds. |
0 |
| ScanRows |
integer |
The number of scanned rows. |
0 |
| ThreadId |
integer |
The thread ID. |
None |
| State |
string |
The execution status. Valid values:
|
0 |
| DBName |
string |
The database name. |
testdb |
| SqlType |
string |
The type of the SQL statement. |
select |
| AccountName |
string |
The database account. |
testname |
| PhysicSyncRead |
integer |
The number of synchronous physical reads. |
0 |
| PhysicAsyncRead |
integer |
The number of asynchronous physical reads. |
0 |
| TrxId |
string |
The transaction ID. |
200000 |
| ReturnRows |
integer |
The number of returned rows. |
0 |
| Consume |
integer |
The execution duration. Unit: microseconds (us). |
58 |
| Vip |
string |
The endpoint that is resolved from the query connection string. |
100.115.XX.XX |
| NodeId |
string |
The node ID. |
pi-uf6k5f6g3912i**** |
| SqlId |
string |
The SQL ID. |
c67649d4a7fb62c4f8c7a447c52b5b17 |
| UseImciEngine |
string |
Indicates whether an In-Memory Column Index (IMCI) is used for the PolarDB for MySQL instance. Valid values:
|
true |
| ParallelQueueTime |
string |
The degree of parallelism for the PolarDB for MySQL instance. |
2 |
| ParallelDegree |
string |
The parallel queuing time, in milliseconds, for a PolarDB for MySQL instance. |
10 |
| Scnt |
integer |
The number of requests from a compute node (CN) to a data node (DN) of a PolarDB-X 2.0 instance. |
10 |
| Rows |
integer |
The total number of rows updated or returned by the compute node of the PolarDB-X 2.0 database instance. |
10 |
| Frows |
integer |
The number of rows pulled by the CN of a PolarDB-X 2.0 instance. |
10 |
| TraceId |
string |
The trace ID of a PolarDB-X 2.0 instance. This is the ID of the SQL statement that is executed on the data node. |
14c93b7c7bf00000 |
| PhysicRead |
integer |
The number of physical reads. |
0 |
| CpuTime |
integer |
The CPU execution time. Unit: microseconds. |
100 |
| Writes |
integer |
The number of writes for an ApsaraDB RDS for SQL Server instance. |
10 |
| Collection |
string |
This parameter is reserved. |
None |
| TableName |
string |
das |
|
| ConnectionId |
string |
ld-****** |
|
| Protocol |
string |
MySQL |
|
| Params |
string |
[1, "das"] |
|
| ClientIp |
string |
10.0.0.1xx |
|
| ClientPort |
integer |
3306 |
|
| RowKey |
string |
23 |
|
| AffectColumns |
string |
["col1"] |
|
| Finish |
string |
Indicates whether the task is complete. Valid values:
Note
If Finish returns 0 and a JobId is returned, the request is asynchronous and the result is not returned immediately. Use the JobId to query the result again. To do this, set the Filters parameter to |
1 |
| JobId |
string |
The ID of the asynchronous task. |
MzI4NTZfUUlOR0RBT19DTTlfTlUyMF9NWVNRTF9PREJTX0xWU18zMjg1Nl9teXNxbF9XZWQgTWFyIDA2IDE0OjUwOjQ3IENTVCAyMDI0XzBfMzBfRXhlY3V0ZVRpbWVfREVTQ19XZWQgTWFyIDA2IDE0OjM1OjQ3IENTVCAyMDI0Xw==_1709708406465 |
Examples
Success response
JSON format
{
"Code": "200",
"Message": "Successful",
"RequestId": "F43E7FB3-CE67-5FFD-A59C-EFD278BCD7BE",
"Success": "true",
"Data": {
"StartTime": 1596177993000,
"EndTime": 1608888296000,
"TotalRecords": 1,
"Items": {
"SQLLogRecord": [
{
"Ext": "None",
"ExecuteTime": "2023-12-07T02:15:32Z",
"OriginTime": 1701886532000,
"HostAddress": "11.197.XX.XX",
"UpdateRows": 0,
"LogicRead": 0,
"SqlText": "select resource_id as cluster_id, tpl_name \\n\\tfrom dbfree_alert_resource_tpl_ref\\n\\twhere user_id=? and type='cluster' group by resource_id, tpl_name",
"LockTime": 0,
"ScanRows": 0,
"ThreadId": 0,
"State": "0",
"DBName": "testdb",
"SqlType": "select",
"AccountName": "testname",
"PhysicSyncRead": 0,
"PhysicAsyncRead": 0,
"TrxId": "200000",
"ReturnRows": 0,
"Consume": 58,
"Vip": "100.115.XX.XX",
"NodeId": "pi-uf6k5f6g3912i****",
"SqlId": "c67649d4a7fb62c4f8c7a447c52b5b17",
"UseImciEngine": "true",
"ParallelQueueTime": "2",
"ParallelDegree": "10",
"Scnt": 10,
"Rows": 10,
"Frows": 10,
"TraceId": "14c93b7c7bf00000 ",
"PhysicRead": 0,
"CpuTime": 100,
"Writes": 10,
"Collection": "None",
"TableName": "das",
"ConnectionId": "ld-******",
"Protocol": "MySQL",
"Params": "[1, \"das\"]",
"ClientIp": "10.0.0.1xx",
"ClientPort": 3306,
"RowKey": "23",
"AffectColumns": "[\"col1\"]"
}
]
},
"Finish": "1",
"JobId": "MzI4NTZfUUlOR0RBT19DTTlfTlUyMF9NWVNRTF9PREJTX0xWU18zMjg1Nl9teXNxbF9XZWQgTWFyIDA2IDE0OjUwOjQ3IENTVCAyMDI0XzBfMzBfRXhlY3V0ZVRpbWVfREVTQ19XZWQgTWFyIDA2IDE0OjM1OjQ3IENTVCAyMDI0Xw==_1709708406465"
}
}
Error codes
|
HTTP status code |
Error code |
Error message |
Description |
|---|---|---|---|
| 400 | InvalidParams | The request parameters are invalid. | |
| 403 | NoPermission | You are not authorized to do this action. |
See Error Codes for a complete list.
Release notes
See Release Notes for a complete list.