This API retrieves slow log records from a database instance, with support for filtering and sorting by various criteria.
Operation description
InstanceIdis the instance ID. This parameter is required.StartTimeandEndTimespecify the time range for the query. These parameters are required.Use the
PageNumberandPageSizeparameters to paginate results.Use the
OrderByparameter to sort results. For details on sortable fields, see the documentation.- Use the
Filtersparameter to refine the query by criteria such as host address or SQL ID.Important Some database types, such as RDS for PostgreSQL and PolarDB for PostgreSQL, do not support specific sorting methods. Select parameters appropriate for your database type.
Try it now
Test
RAM authorization
|
Action |
Access level |
Resource type |
Condition key |
Dependent action |
|
hdm:DescribeSlowLogRecords |
get |
*All Resource
|
None | None |
Request parameters
|
Parameter |
Type |
Required |
Description |
Example |
| InstanceId |
string |
Yes |
The instance ID. |
rm-8vbk4xz99su8**** |
| NodeId |
string |
No |
The node ID. |
pi-d9j9fe7wq7t9i**** |
| StartTime |
integer |
Yes |
The start time of the query range. This value is a UNIX timestamp representing the number of milliseconds that have elapsed since January 1, 1970, 00:00:00 UTC. |
1596177993000 |
| EndTime |
integer |
Yes |
The end time of the query range. This value is a UNIX timestamp representing the number of milliseconds that have elapsed since January 1, 1970, 00:00:00 UTC. |
1634972640000 |
| PageNumber |
integer |
No |
The page number of the page to return. The pages start from page 1. |
1 |
| PageSize |
integer |
No |
The number of entries to return on each page. |
10 |
| Filters |
array<object> |
No |
The filter conditions. |
|
|
object |
No |
A filter condition. |
||
| Key |
string |
No |
The name of the filter parameter. Note
For more information, see the "Supplementary information about request parameters" section. |
None |
| Value |
string |
No |
The value of the filter parameter. |
None |
| OrderBy |
string |
No |
Important Sorting is not supported for ApsaraDB RDS for PostgreSQL, PolarDB for PostgreSQL (Compatible with Oracle), and ApsaraDB for SQL Server instances. |
QueryTimeSeconds |
| Asc |
boolean |
No |
Specifies whether to sort the results in ascending order. Default value: true.
|
true |
The Key parameter supports the following values:
- RDS for MySQL, PolarDB for MySQL, RDS for PostgreSQL, and PolarDB for PostgreSQL
hostAddress: Source IP address. Separate multiple values with commas.
sqlId: SQL ID. Separate multiple values with commas.
user: User. Separate multiple values with commas.
dbName: Database name. Separate multiple values with commas.
tags: Tag. Separate multiple values with commas.
- MongoDB
hostInsId: Role ID. Separate multiple values with commas.
insRole: Instance role. Separate multiple values with commas.
opType: Operation type. Separate multiple values with commas.
namespace: Namespace. Separate multiple values with commas.
nodeType: Component type. Separate multiple values with commas.
queryId: Query ID. Separate multiple values with commas.
- Tair
hostAddress: Source IP address.
user: User.
dbName: Database name.
nodeType: Node type.
- RDS for SQL Server
hostAddress: Source IP address. Separate multiple values with commas.
sqlId: SQL ID. Separate multiple values with commas.
user: User. Separate multiple values with commas.
dbName: Database name. Separate multiple values with commas.
tags: Tag. Separate multiple values with commas.
- PolarDB-X
traceId: Trace ID.
role: Node role. This parameter is required. Valid values:
CN(compute node) andDN(data node).hostAddress: Source IP address. Separate multiple values with commas.
sqlId: SQL ID. Separate multiple values with commas.
user: User. Separate multiple values with commas.
dbName: Database name. Separate multiple values with commas.
tags: Tag. Separate multiple values with commas.
For the SQL engine, you can query data by
sqlId. The sqlId parameter accepts up to 20 comma-separated values.For MongoDB, you can query data by
queryId. The queryId parameter accepts up to 20 comma-separated values.
Response elements
|
Element |
Type |
Description |
Example |
|
object |
|||
| Code |
string |
The response status code. |
200 |
| Message |
string |
The response message. Note
If the request is successful, Successful is returned. If the request fails, an error message is returned. |
Successful |
| RequestId |
string |
The request ID. |
A1C79EE2-D04D-571B-8C60-961FAF8E**** |
| Success |
string |
Indicates whether the request was successful. Valid values:
|
true |
| Data |
object |
The details of the slow query logs. |
|
| DbInstanceName |
string |
The instance ID. |
rm-bp157g54vy772**** |
| NodeId |
string |
The node ID. |
node123 |
| ItemsNumbers |
integer |
The number of slow log records on the current page. |
10 |
| StartTime |
string |
The start time. |
1672531200000 |
| EndTime |
string |
The end time. |
1672617600000 |
| DbInstanceId |
integer |
The numeric ID of the instance. |
100 |
| TotalRecords |
integer |
The total number of entries. |
100 |
| PageNumbers |
integer |
The page number. Pages start from 1. The default value is 1. |
1 |
| MaxRecordsPerPage |
integer |
The maximum number of entries to return on each page. Valid values: 5 to 100. |
20 |
| Logs |
array<object> |
An array of slow query log records. |
|
|
array<object> |
A slow query log record. |
||
| SqlId |
string |
The SQL template ID. |
sqlId |
| Scheme |
string |
The data schema. |
HTTPS |
| SubInstanceId |
string |
The sub-instance ID. |
r-8vb219d10038**** |
| DbInstanceName |
string |
The instance ID. |
rm-2zebg30mk056g**** |
| InsName |
string |
The instance name. |
test |
| AccountName |
string |
The account name. |
user1 |
| HostAddress |
string |
The source IP address. |
192.168.1.1 |
| QueryStartTime |
string |
The time when the query started. The time is in the yyyy-MM-dd hh:mm:ss format and is displayed in UTC. |
2024-04-01 11:00:00 |
| SQLText |
string |
The SQL statement. |
SELECT * FROM my_table WHERE ROWNUM <= 10 |
| Psql |
string |
The SQL template. |
SELECT * FROM my_table WHERE ROWNUM <= 10 |
| DBName |
string |
The database name. |
test |
| QueryTime |
integer |
The query execution duration, in milliseconds. |
121 |
| ReturnItemNumbers |
string |
The numbers of the returned items. |
test |
| DocsExamined |
string |
The number of documents scanned. Note This parameter is returned only for ApsaraDB for MongoDB instances. |
100 |
| KeysExamined |
string |
The number of index entries scanned. Note This parameter is returned only for ApsaraDB for MongoDB instances. |
valueA |
| TableName |
string |
The table name. |
tableNameExample |
| LockTime |
number |
The lock wait duration, in milliseconds. |
100 |
| RowsExamined |
integer |
The number of rows scanned. |
100 |
| RowsSent |
integer |
The number of rows returned. |
10 |
| ThreadId |
string |
The thread ID. |
57472578 |
| Timestamp |
integer |
The Unix timestamp. Unit: seconds. |
1747118812 |
| SqlTag |
object |
The details about the SQL tag. |
|
| SqlId |
string |
The SQL template ID. |
8ad7069f236bcdaaa9b3ae4b6299**** |
| Tags |
string |
The tags. Multiple tags are separated by commas ( |
DAS_IMPORTANT,DAS_IN_PLAN |
| Comments |
string |
The remarks. |
test |
| LockTimeSeconds |
number |
The lock wait duration, in seconds. |
100 |
| QueryTimeSeconds |
number |
The query execution duration, in seconds. |
100 |
| SqlType |
string |
The type of the SQL statement. Valid values:
|
SELECT |
| CPUTime |
number |
The CPU time consumed by the query. Note
This parameter is returned only for ApsaraDB RDS for SQL Server instances. |
50 |
| IOWrites |
integer |
The number of I/O writes. Note
This parameter is returned only for ApsaraDB RDS for SQL Server instances. |
1 |
| LastRowsCountAffected |
integer |
The number of rows affected by the last statement. Note
This parameter is returned only for ApsaraDB RDS for SQL Server instances. |
10 |
| LogicalIOReads |
integer |
The number of logical reads. Note
This parameter is returned only for ApsaraDB RDS for SQL Server instances. |
1 |
| PhysicalIOReads |
integer |
The number of physical reads. Note
This parameter is returned only for ApsaraDB RDS for SQL Server instances. |
1 |
| RowsCountAffected |
integer |
The number of affected rows. Note
This parameter is returned only for ApsaraDB RDS for SQL Server instances. |
10 |
| Command |
string |
The slow query statement. Note
This parameter is returned only for Tair instances. |
SELECT |
| Namespace |
string |
The namespace. Note
This parameter is returned only for ApsaraDB for MongoDB instances. |
pro-test |
| QueryId |
string |
The query ID. Note
This parameter is returned only for ApsaraDB for MongoDB instances. |
sq-1pzcdMwRb |
| ReturnNum |
string |
The number of rows returned, as a string. Note
This parameter is returned only for ApsaraDB for MongoDB instances. |
20 |
| ApplicationName |
string |
The application name. Note
This parameter is returned only for ApsaraDB RDS for SQL Server instances. |
MyApp |
| CPUTimeSeconds |
number |
The CPU time consumed by the query, in seconds. Note
This parameter is returned only for ApsaraDB RDS for SQL Server instances. |
100 |
| Rows |
integer |
The total number of rows updated or returned by the compute node of a PolarDB-X 2.0 instance. Note
This parameter is returned only for PolarDB-X 2.0 instances. |
20 |
| Frows |
integer |
The number of rows fetched by the compute node (CN) of a PolarDB-X 2.0 instance. Note
This parameter is returned only for PolarDB-X 2.0 instances. |
10 |
| Scnt |
integer |
The number of requests sent from the compute node (CN) to data nodes (DNs) in a PolarDB-X 2.0 instance. Note
This parameter is returned only for PolarDB-X 2.0 instances. |
10 |
| TraceId |
string |
The trace ID for a PolarDB-X 2.0 instance. It represents the execution ID of an SQL statement on a data node. Note
This parameter is returned only for PolarDB-X 2.0 instances. |
074ce334-5247-40b9-b0c1-158aea5d**** |
| TemplateId |
string |
The template ID of a PolarDB-X 2.0 instance. Note
This parameter is returned only for PolarDB-X 2.0 instances. |
6a63b6ac4572abfaef7d1163f684**** |
| NodeId |
string |
The node ID. |
|
| Cmd |
string |
The command that is used to query data. Note This parameter is returned only for Tair instances. |
|
| Rt |
integer |
The execution duration. Unit: microseconds. Note This parameter is returned only for Tair instances. |
|
| RequestSize |
integer |
The size of the request. Unit: bytes. Note This parameter is returned only for Tair instances. |
|
| ResponseSize |
integer |
The size of the response. Unit: bytes. Note This parameter is returned only for Tair instances. |
|
| ClientIp |
string |
The IP address of the client. Note This parameter is returned only for Tair instances. |
|
| DbId |
string |
The ID of the database. Note This parameter is returned only for Tair instances. |
|
| OriginTime |
string |
The time when the command was executed. The time is in the yyyy-MM-ddTHH:mm:ssZ format and is displayed in UTC. Note This parameter is returned only for ApsaraDB for MongoDB instances. |
|
| OpType |
string |
The operation type. Note This parameter is returned only for ApsaraDB for MongoDB instances. |
|
| Fail |
string |
Indicates whether the command failed to be executed. Note This parameter is returned only for ApsaraDB for MongoDB instances. |
|
| Params |
string |
The parameters of the command. Note This parameter is returned only for ApsaraDB for MongoDB instances. |
|
| Reason |
string |
The reason why the command failed to be executed. Note This parameter is returned only for ApsaraDB for MongoDB instances. |
|
| ReqId |
string |
The request ID. Note This parameter is returned only for ApsaraDB for MongoDB instances. |
Examples
Success response
JSON format
{
"Code": "200",
"Message": "Successful",
"RequestId": "A1C79EE2-D04D-571B-8C60-961FAF8E****",
"Success": "true",
"Data": {
"DbInstanceName": "rm-bp157g54vy772****",
"NodeId": "node123",
"ItemsNumbers": 10,
"StartTime": "1672531200000",
"EndTime": "1672617600000",
"DbInstanceId": 100,
"TotalRecords": 100,
"PageNumbers": 1,
"MaxRecordsPerPage": 20,
"Logs": [
{
"SqlId": "sqlId",
"Scheme": "HTTPS",
"SubInstanceId": "r-8vb219d10038****",
"DbInstanceName": "rm-2zebg30mk056g****",
"InsName": "test",
"AccountName": "user1",
"HostAddress": "192.168.1.1",
"QueryStartTime": "2024-04-01 11:00:00",
"SQLText": "SELECT * FROM my_table WHERE ROWNUM <= 10",
"Psql": "SELECT * FROM my_table WHERE ROWNUM <= 10\n",
"DBName": "test",
"QueryTime": 121,
"ReturnItemNumbers": "test",
"DocsExamined": "100",
"KeysExamined": "valueA",
"TableName": "tableNameExample",
"LockTime": 100,
"RowsExamined": 100,
"RowsSent": 10,
"ThreadId": "57472578",
"Timestamp": 1747118812,
"SqlTag": {
"SqlId": "8ad7069f236bcdaaa9b3ae4b6299****",
"Tags": "DAS_IMPORTANT,DAS_IN_PLAN",
"Comments": "test"
},
"LockTimeSeconds": 100,
"QueryTimeSeconds": 100,
"SqlType": "SELECT",
"CPUTime": 50,
"IOWrites": 1,
"LastRowsCountAffected": 10,
"LogicalIOReads": 1,
"PhysicalIOReads": 1,
"RowsCountAffected": 10,
"Command": "SELECT",
"Namespace": "pro-test",
"QueryId": "sq-1pzcdMwRb",
"ReturnNum": "20",
"ApplicationName": "MyApp",
"CPUTimeSeconds": 100,
"Rows": 20,
"Frows": 10,
"Scnt": 10,
"TraceId": "074ce334-5247-40b9-b0c1-158aea5d****",
"TemplateId": "6a63b6ac4572abfaef7d1163f684****",
"NodeId": "",
"Cmd": "",
"Rt": 0,
"RequestSize": 0,
"ResponseSize": 0,
"ClientIp": "",
"DbId": "",
"OriginTime": "",
"OpType": "",
"Fail": "",
"Params": "",
"Reason": "",
"ReqId": ""
}
]
}
}
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.