调用DescribeSlowLogs查询慢日志统计情况。

调用该接口时,实例必须为如下版本:

  • MySQL所有版本(MySQL 5.7基础版除外);
  • SQL Server 2008 R2;
  • MariaDB 10.3。
说明 慢日志统计非实时采集,可能会有6~8小时的延迟。

调试

您可以在OpenAPI Explorer中直接运行该接口,免去您计算签名的困扰。运行成功后,OpenAPI Explorer可以自动生成SDK代码示例。

请求参数

名称 类型 是否必选 示例值 描述
Action String 是 DescribeSlowLogs

系统规定参数。取值:DescribeSlowLogs。

DBInstanceId String 是 rm-uf6wjk5xxxxxxx

实例ID。

StartTime String 是 2011-05-01Z

查询开始日期,格式:yyyy-MM-ddZ(UTC时间)。

EndTime String 是 2011-05-30Z

查询结束日期,不能小于查询开始日期,与查询开始日期间隔不超过31天。格式:yyyy-MM-ddZ(UTC时间)。

DBName String 否 RDS_MySQL

数据库名称。

SortKey String 否 TotalExecutionCounts

排序依据,取值:

  • TotalExecutionCounts:总执行次数最多
  • TotalQueryTimes:总执行时间最多
  • TotalLogicalReads:总逻辑读最多
  • TotalPhysicalReads:总物理读最多
说明 仅SQL Server 2008 R2实例支持本参数。
PageSize Integer 否 30

每页记录数,取值:30~100。默认值:30。

PageNumber Integer 否 1

页码,取值:大于0且不超过Integer的最大值。

默认值:1。

返回数据

名称 类型 示例值 描述
EndTime String 2011-05-30Z

查询结束日期。

StartTime String 2011-05-30Z

查询开始日期。

RequestId String 2553A660-E4EB-4AF4-A402-8AFF70A49143

请求ID。

PageRecordCount Integer 10

本页SQL语句个数。

TotalRecordCount Integer 5

总记录数。

DBInstanceId String rm-uf6wjk5xxxxxxx

实例ID。

PageNumber Integer 1

页码。

Engine String MySQL

数据库类型。

Items Array of SQLSlowLog

慢日志信息列表。

SQLSlowLog
MaxLastRowsAffectedCounts Long 0

最后一次受影响的行数(最大值)。

说明 仅SQL Server实例支持返回该参数。
ReturnMaxRowCount Long 1

返回的SQL行数(最大值)。

SQLText String select id,name from tb_table

SQL语句。

SQLServerMaxCpuTime Long 0

CPU查询时间(最大值),单位:秒。

说明 仅SQL Server实例支持返回该参数。
CreateTime String 2011-05-30Z

数据生成日期。

AvgLastRowsAffectedCounts Long 0

最后一次受影响的行数(平均值)。

说明 仅SQL Server实例支持返回该参数。
MinLastRowsAffectedCounts Long 0

最后一次受影响的行数(最小值)。

说明 仅SQL Server实例支持返回该参数。
ParseTotalRowCounts Long 1

解析的SQL行数(总值)。

TotalLockTimes Long 0

锁定时长(总值),单位:秒。

MySQLTotalExecutionCounts Long 1

MySQL执行次数(总值)。

SQLServerMinCpuTime Long 0

CPU查询时间(最小值),单位:秒。

说明 仅SQL Server实例支持返回该参数。
SQLHASH String U2FsdGVkxxxx

慢日志统计里的SQL语句唯一标识符,可用于获取该SQL语句的慢日志明细。

MinIOWriteCounts Long 0

I/O写次数(最小值)。

说明 仅SQL Server实例支持返回该参数。
ParseMaxRowCount Long 1

解析的SQL行数(最大值)。

MaxLogicalReadCounts Long 0

逻辑读次数(最大值)。

说明 仅SQL Server实例支持返回该参数。
MySQLTotalExecutionTimes Long 1

MySQL执行时长(总值),单位:秒。

SQLServerTotalExecutionCounts Long 1

SQL Server执行次数(总值)。

ReturnTotalRowCounts Long 1

返回的SQL行数(总值)。

MaxLockTime Long 0

锁定时长(最大值),单位:秒。

DBName String RDS_MySQL

数据库名称。

MinRowsAffectedCounts Long 0

受影响的行数(最小值)。

说明 仅SQL Server实例支持返回该参数。
TotalLogicalReadCounts Long 1

逻辑读次数(总值)。

TotalPhysicalReadCounts Long 1

物理读次数(总值)。

ReportTime String 2011-05-30Z

数据报表生成日期。

MaxPhysicalReadCounts Long 0

物理读次数(最大值)。

说明 仅SQL Server实例支持返回该参数。
SQLServerTotalCpuTime Long 0

CPU查询时间(总值),单位:秒。

说明 仅SQL Server实例支持返回该参数。
TotalIOWriteCounts Long 0

I/O写次数(总值)。

说明 仅SQL Server实例支持返回该参数。
MaxRowsAffectedCounts Long 0

受影响的行数(最大值)。

说明 仅SQL Server实例支持返回该参数。
AvgIOWriteCounts Long 0

I/O写次数(平均值)。

说明 仅SQL Server实例支持返回该参数。
MinPhysicalReadCounts Long 0

物理读次数(最小值)。

说明 仅SQL Server实例支持返回该参数。
SlowLogId Long 26584213

慢查询汇总标识ID。

MaxExecutionTime Long 60

执行时长(最大值),单位:秒。

AvgExecutionTime Long 1

执行时间(平均值),单位:秒。

说明 仅SQL Server实例支持返回该参数。
SQLServerAvgExecutionTime Long 0

执行时间(平均值),单位:秒。

说明 仅SQL Server实例支持返回该参数。
MaxIOWriteCounts Long 0

I/O写次数(最大值)。

说明 仅SQL Server实例支持返回该参数。
SQLServerAvgCpuTime Long 0

CPU查询时间(平均值),单位:秒。

说明 仅SQL Server实例支持返回该参数。
TotalLastRowsAffectedCounts Long 0

最后一次受影响的行数(总值)。

说明 仅SQL Server实例支持返回该参数。
AvgLogicalReadCounts Long 0

逻辑读次数(平均值)。

说明 仅SQL Server实例支持返回该参数。
SQLServerMinExecutionTime Long 0

执行时间(最小值),单位:秒。

说明 仅SQL Server实例支持返回该参数。
SQLIdStr String 521584

对应的是慢日志统计模版SQL的ID,现已废弃,请使用SQLHASH。

SQLServerTotalExecutionTimes Long 1000

SQL Server执行时长(总值),单位:毫秒。

AvgRowsAffectedCounts Long 0

受影响的行数(平均值)。

说明 仅SQL Server实例支持返回该参数。
TotalRowsAffectedCounts Long 0

影响的行数(总值)。

AvgPhysicalReadCounts Long 0

物理读次数(平均值)。

说明 仅SQL Server实例支持返回该参数。
MinLogicalReadCounts Long 0

逻辑读次数(最小值)。

说明 仅SQL Server实例支持返回该参数。

示例

请求示例

http(s)://rds.aliyuncs.com/?Action=DescribeSlowLogs
&DBInstanceId=rm-uf6wjk5xxxxxxx
&StartTime=2011-05-01Z
&EndTime=2011-05-30Z
&<公共请求参数>

正常返回示例

XML格式

HTTP/1.1 200 OK
Content-Type:application/xml

<DescribeSlowLogsResponse>
    <EndTime>2011-05-30Z</EndTime>
    <StartTime>2011-05-30Z</StartTime>
    <RequestId>2553A660-E4EB-4AF4-A402-8AFF70A49143</RequestId>
    <PageRecordCount>10</PageRecordCount>
    <TotalRecordCount>5</TotalRecordCount>
    <DBInstanceId>rm-uf6wjk5xxxxxxx</DBInstanceId>
    <PageNumber>1</PageNumber>
    <Engine>MySQL</Engine>
    <Items>
        <MaxLastRowsAffectedCounts>0</MaxLastRowsAffectedCounts>
        <ReturnMaxRowCount>1</ReturnMaxRowCount>
        <SQLText>select id,name from tb_table</SQLText>
        <SQLServerMaxCpuTime>0</SQLServerMaxCpuTime>
        <CreateTime>2011-05-30Z</CreateTime>
        <AvgLastRowsAffectedCounts>0</AvgLastRowsAffectedCounts>
        <MinLastRowsAffectedCounts>0</MinLastRowsAffectedCounts>
        <ParseTotalRowCounts>1</ParseTotalRowCounts>
        <TotalLockTimes>0</TotalLockTimes>
        <MySQLTotalExecutionCounts>1</MySQLTotalExecutionCounts>
        <SQLServerMinCpuTime>0</SQLServerMinCpuTime>
        <SQLHASH>U2FsdGVkxxxx</SQLHASH>
        <MinIOWriteCounts>0</MinIOWriteCounts>
        <ParseMaxRowCount>1</ParseMaxRowCount>
        <MaxLogicalReadCounts>0</MaxLogicalReadCounts>
        <MySQLTotalExecutionTimes>1</MySQLTotalExecutionTimes>
        <SQLServerTotalExecutionCounts>1</SQLServerTotalExecutionCounts>
        <ReturnTotalRowCounts>1</ReturnTotalRowCounts>
        <MaxLockTime>0</MaxLockTime>
        <DBName>RDS_MySQL</DBName>
        <MinRowsAffectedCounts>0</MinRowsAffectedCounts>
        <TotalLogicalReadCounts>1</TotalLogicalReadCounts>
        <TotalPhysicalReadCounts>1</TotalPhysicalReadCounts>
        <ReportTime>2011-05-30Z</ReportTime>
        <MaxPhysicalReadCounts>0</MaxPhysicalReadCounts>
        <SQLServerTotalCpuTime>0</SQLServerTotalCpuTime>
        <TotalIOWriteCounts>0</TotalIOWriteCounts>
        <MaxRowsAffectedCounts>0</MaxRowsAffectedCounts>
        <AvgIOWriteCounts>0</AvgIOWriteCounts>
        <MinPhysicalReadCounts>0</MinPhysicalReadCounts>
        <SlowLogId>26584213</SlowLogId>
        <MaxExecutionTime>60</MaxExecutionTime>
        <AvgExecutionTime>1</AvgExecutionTime>
        <SQLServerAvgExecutionTime>0</SQLServerAvgExecutionTime>
        <MaxIOWriteCounts>0</MaxIOWriteCounts>
        <SQLServerAvgCpuTime>0</SQLServerAvgCpuTime>
        <TotalLastRowsAffectedCounts>0</TotalLastRowsAffectedCounts>
        <AvgLogicalReadCounts>0</AvgLogicalReadCounts>
        <SQLServerMinExecutionTime>0</SQLServerMinExecutionTime>
        <SQLIdStr>521584</SQLIdStr>
        <SQLServerTotalExecutionTimes>1000</SQLServerTotalExecutionTimes>
        <AvgRowsAffectedCounts>0</AvgRowsAffectedCounts>
        <TotalRowsAffectedCounts>0</TotalRowsAffectedCounts>
        <AvgPhysicalReadCounts>0</AvgPhysicalReadCounts>
        <MinLogicalReadCounts>0</MinLogicalReadCounts>
    </Items>
</DescribeSlowLogsResponse>

JSON格式

HTTP/1.1 200 OK
Content-Type:application/json

{
  "EndTime" : "2011-05-30Z",
  "StartTime" : "2011-05-30Z",
  "RequestId" : "2553A660-E4EB-4AF4-A402-8AFF70A49143",
  "PageRecordCount" : 10,
  "TotalRecordCount" : 5,
  "DBInstanceId" : "rm-uf6wjk5xxxxxxx",
  "PageNumber" : 1,
  "Engine" : "MySQL",
  "Items" : [ {
    "MaxLastRowsAffectedCounts" : 0,
    "ReturnMaxRowCount" : 1,
    "SQLText" : "select id,name from tb_table",
    "SQLServerMaxCpuTime" : 0,
    "CreateTime" : "2011-05-30Z",
    "AvgLastRowsAffectedCounts" : 0,
    "MinLastRowsAffectedCounts" : 0,
    "ParseTotalRowCounts" : 1,
    "TotalLockTimes" : 0,
    "MySQLTotalExecutionCounts" : 1,
    "SQLServerMinCpuTime" : 0,
    "SQLHASH" : "U2FsdGVkxxxx",
    "MinIOWriteCounts" : 0,
    "ParseMaxRowCount" : 1,
    "MaxLogicalReadCounts" : 0,
    "MySQLTotalExecutionTimes" : 1,
    "SQLServerTotalExecutionCounts" : 1,
    "ReturnTotalRowCounts" : 1,
    "MaxLockTime" : 0,
    "DBName" : "RDS_MySQL",
    "MinRowsAffectedCounts" : 0,
    "TotalLogicalReadCounts" : 1,
    "TotalPhysicalReadCounts" : 1,
    "ReportTime" : "2011-05-30Z",
    "MaxPhysicalReadCounts" : 0,
    "SQLServerTotalCpuTime" : 0,
    "TotalIOWriteCounts" : 0,
    "MaxRowsAffectedCounts" : 0,
    "AvgIOWriteCounts" : 0,
    "MinPhysicalReadCounts" : 0,
    "SlowLogId" : 26584213,
    "MaxExecutionTime" : 60,
    "AvgExecutionTime" : 1,
    "SQLServerAvgExecutionTime" : 0,
    "MaxIOWriteCounts" : 0,
    "SQLServerAvgCpuTime" : 0,
    "TotalLastRowsAffectedCounts" : 0,
    "AvgLogicalReadCounts" : 0,
    "SQLServerMinExecutionTime" : 0,
    "SQLIdStr" : "521584",
    "SQLServerTotalExecutionTimes" : 1000,
    "AvgRowsAffectedCounts" : 0,
    "TotalRowsAffectedCounts" : 0,
    "AvgPhysicalReadCounts" : 0,
    "MinLogicalReadCounts" : 0
  } ]
}

错误码

HttpCode 错误码 错误信息 描述
400 InvalidSearchTimeRange search time range cannot be longer than a month. 查询结束时间(参数名称:EndTime)与查询开始时间(参数名称:StartTime)的间隔应小于31天,请输入正确的相关参数。
400 IO.Exception IO exception, retry later. io异常。

访问错误中心查看更多错误码。