You need to enable JavaScript to run this app.
导航
DescribeTopicPartitions - 查看 Topic 分区
最近更新时间:2024.09.26 15:55:18首次发布时间:2023.03.30 19:59:26

调用 DescribeTopicPartitions 接口获取 Topic 的 Partition 信息。

使用说明

DescribeTopicPartitions 接口提供分页式的查询功能,供您查看指定 Topic 的分区数量、分区 ISR 状态等信息。

调试

请求参数

下表仅列出该接口特有的请求参数和部分公共参数。更多信息请见公共参数

参数
类型
是否必填
示例值
描述
Action
String

DescribeTopicPartitions

要执行的操作,取值:DescribeTopicPartitions。

Version
String

2022-05-01

API的版本,取值:2022-05-01。

InstanceId
String

kafka-cnngbnntswg1****x

实例 ID。

TopicName
String

my_topic

Topic 名称。

PageNumber
Integer

1

列表的页码,最小值为 1。

PageSize
Integer

10

列表中每一页的条目数量,取值范围为 1~100。

PartitionIds
Array of Integer

[1,2]

分区编号。若未指定,则返回所有分区的信息。

UnderInsyncOnly
Boolean

true

是否只查询存在不同步副本的分区列表,默认值为 false。

  • true:只查询存在不同步副本的分区列表。
  • false:(默认)查询全部分区列表。

返回参数

下表仅列出本接口特有的返回参数。更多信息请参见返回结构

参数
类型
示例值
描述
Total
Integer

2

符合查询条件的分区总数。

PartitionsInfo
Array of Object

--

符合查询条件的分区列表。

请求示例

POST /?Action=DescribeTopicPartitions&Version=2022-05-01 HTTP/1.1
Content-Type: application/json
Host: kafka.volcengineapi.com
X-Date: 20210328T100802Z
Authorization: HMAC-SHA256 Credential=AK********/20210328/cn-beijing/Kafka/request, SignedHeaders=x-date, Signature=********

{
  "InstanceId": "kafka-cnngbnntswg1****",
  "TopicName": "my_topic",
  "PageNumber": 1,
  "PageSize": 1
}

返回示例

{
    "ResponseMetadata": {
        "RequestId": "2023022720063227B3DCC115F59769D448",
        "Action": "DescribeTopicPartitions",
        "Version": "2022-05-01",
        "Service": "Kafka",
        "Region": "cn-beijing"
    },
    "Result": {
        "PartitionsInfo": [
            {
                "EndOffset": 7774940552,
                "InsyncReplicas": [
                    2,
                    1,
                    0
                ],
                "Leader": 2,
                "MessageCount": 16286430,
                "PartitionId": 0,
                "Replicas": [
                    2,
                    1,
                    0
                ],
                "StartOffset": 7758654122,
                "UnderInsyncReplicas": []
            }
        ],
        "Total": 2
    }
}

错误码

下表为您列举了该接口与业务逻辑相关的错误码。公共错误码请参见公共错误码文档。

状态码
错误码
错误信息
说明
400
InvalidParameter
The specified parameter is not valid.

参数值无效。

403
OperationDenied.AccountNotAuthorized
You are not authorized to perform this operation.

您不具备相关权限 ,请授权或切换账号后重试。

403
OperationDenied.InvalidInstanceStatus
The operation is not valid for the current status of the instance.

当前实例状态不允许执行该操作。

403
OperationDenied.InvalidTopicStatus
The operation is not valid for the current status of the topic.

当前Kafka主题状态不允许执行该操作。

404
InvalidInstanceId.NotFound
The specified Instance ID does not exist.

实例不存在。

404
InvalidTopicName.NotFound
The specified topic does not exist.

Topic不存在。

500
InternalError
The request failed due to some unknown error, exception or failure.

内部错误,请稍后重试。