调用DescribeSlowLogTrend接口查询社区兼容版集群的慢SQL趋势。

调试

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

请求参数

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

系统规定参数。取值:DescribeSlowLogTrend

RegionId String cn-hangzhou

地域ID。您可以通过调用DescribeRegions接口查询地域ID。

DBClusterId String cc-bp11xxl475ui8****

集群ID。您可以通过调用DescribeDBClusters接口查询目标地域下所有的集群信息,包括集群ID。

StartTime String 2022-05-20 16:00:00

查询开始时间。格式:yyyy-MM-dd hh:mm:ss(UTC时间)。

EndTime String 2022-05-27 16:00:00

查询结束时间,格式:yyyy-MM-dd hh:mm:ss(UTC时间)。

说明 查询结束时间需晚于查询开始时间,且与查询开始时间间隔小于7天。
QueryDurationMs Integer 1000

慢SQL的执行耗时。最小值为1000,默认值为1000。单位:毫秒。返回参数将返回超过该耗时的慢SQL。

返回数据

名称 类型 示例值 描述
RequestId String 7D3ECB0E-98CA-5E08-A9CA-F70C5A1E9BDF

请求ID。

SlowLogTrend Object

慢SQL的结果集合。

TableSchema Array of ResultSet

表结构。

ResultSet
Type String UInt64

列类型。

Name String query_start_time

列名。

Data Array of ResultSet

慢SQL列表。

ResultSet
QueryStartTime String 2022-05-22 20:00:01

查询开始的时间。格式:yyyy-MM-dd hh:mm:ss(UTC时间)。

MaxQueryDurationMs String 3000

最长执行耗时。单位:毫秒。

MinQueryDurationMs String 1000

最短执行耗时。单位:毫秒。

Count String 4000

慢SQL执行耗时的总和。单位:毫秒。

AvgQueryDurationMs String 2000

平均执行耗时。单位:毫秒。

Rows String 1

返回结果集的行数。

RowsBeforeLimitAtLeast String 1

分页大小。

Statistics Object

查询结果的统计信息。

RowsRead Integer 14721

读取的行数。

ElapsedTime Float 0.001703578

读取SQL的耗时。单位:毫秒。

BytesRead Integer 697899

读取的数据量大小。单位:Byte。

示例

请求示例

http(s)://clickhouse.aliyuncs.com/?Action=DescribeSlowLogTrend
&RegionId=cn-hangzhou
&DBClusterId=cc-bp11xxl475ui8****
&StartTime=2022-05-20 16:00:00
&EndTime=2022-05-27 16:00:00
&QueryDurationMs=1000
&公共请求参数

正常返回示例

XML格式

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

<DescribeSlowLogTrendResponse>
    <RequestId>7D3ECB0E-98CA-5E08-A9CA-F70C5A1E9BDF</RequestId>
    <SlowLogTrend>
        <TableSchema>
            <Type>UInt64</Type>
            <Name>query_start_time</Name>
        </TableSchema>
        <Data>
            <QueryStartTime>2022-05-22 20:00:01</QueryStartTime>
            <MaxQueryDurationMs>3000</MaxQueryDurationMs>
            <MinQueryDurationMs>1000</MinQueryDurationMs>
            <Count>4000</Count>
            <AvgQueryDurationMs>2000</AvgQueryDurationMs>
        </Data>
        <Rows>1</Rows>
        <RowsBeforeLimitAtLeast>1</RowsBeforeLimitAtLeast>
        <Statistics>
            <RowsRead>14721</RowsRead>
            <ElapsedTime>0.001703578</ElapsedTime>
            <BytesRead>697899</BytesRead>
        </Statistics>
    </SlowLogTrend>
</DescribeSlowLogTrendResponse>

JSON格式

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

{
  "RequestId" : "7D3ECB0E-98CA-5E08-A9CA-F70C5A1E9BDF",
  "SlowLogTrend" : {
    "TableSchema" : [ {
      "Type" : "UInt64",
      "Name" : "query_start_time"
    } ],
    "Data" : [ {
      "QueryStartTime" : "2022-05-22 20:00:01",
      "MaxQueryDurationMs" : "3000",
      "MinQueryDurationMs" : "1000",
      "Count" : "4000",
      "AvgQueryDurationMs" : "2000"
    } ],
    "Rows" : "1",
    "RowsBeforeLimitAtLeast" : "1",
    "Statistics" : {
      "RowsRead" : 14721,
      "ElapsedTime" : 0.001703578,
      "BytesRead" : 697899
    }
  }
}

错误码

HttpCode 错误码 错误信息 描述
500 InternalError An error occurred while processing your request. 系统内部错误,请稍后重试
503 ServiceUnavailable An error occurred while processing your request. 系统暂时不可用,请稍后重试

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