Kafka配置检查器
项目描述
kafkacfg
: Kafka配置分析CLI
Kafka有很多参数、可调整项和旋钮,而配置页面并不容易解析。kafkacfg
允许您分析您的Kafka配置文件,帮助您了解它在做什么。
[!NOTE]所有
kafkacfg
命令(除了kafkacfg recommends
)都可以传递一个--source librdkafka
参数,用于处理librdkafka
的配置参数而不是Kafka参数
kafkacfg explain
此命令用于显示配置文件中使用的每个配置可调整项的额外信息。
$ cat samples/server.properties
num.io.threads = 10
broker.id = 1001
auto.create.topics.enable = false
background.threads = 10
$ kafkacfg explain -k 3.4 samples/server.properties | jq .
[
{
"name": "num.io.threads",
"override": "10",
"description": "The number of threads that the server uses for processing requests, which may include disk I/O",
"scope": "broker",
"type": "int",
"default": "8",
"valid_values": "[1,...]",
"importance": "high",
"update_mode": "cluster-wide"
},
{
"name": "broker.id",
"override": "1001",
"description": "The broker id for this server. If unset, a unique broker id will be generated.To avoid conflicts between zookeeper generated broker id's and user configured broker id's, generated broker ids start from reserved.broker.max.id + 1.",
"scope": "broker",
"type": "int",
"default": "-1",
"valid_values": null,
"importance": "high",
"update_mode": "read-only"
},
{
"name": "auto.create.topics.enable",
"override": "false",
"description": "Enable auto creation of topic on the server",
"scope": "broker",
"type": "boolean",
"default": "true",
"valid_values": null,
"importance": "high",
"update_mode": "read-only"
},
{
"name": "background.threads",
"override": "10",
"description": "The number of threads to use for various background processing tasks",
"scope": "broker",
"type": "int",
"default": "10",
"valid_values": "[1,...]",
"importance": "high",
"update_mode": "cluster-wide"
}
]
此格式使得通过如jtbl
等表格格式化工具进行管道传输变得容易。
$ kafkacfg explain -k 3.4 samples/server.properties | jtbl
╒═══════════════════════════╤════════════╤═══════════════════════════════════════════════════════════════════════╤═════════╤═════════╤═══════════╤════════════════╤══════════════╤═══════════════╕
│ name │ override │ description │ scope │ type │ default │ valid_values │ importance │ update_mode │
╞═══════════════════════════╪════════════╪═══════════════════════════════════════════════════════════════════════╪═════════╪═════════╪═══════════╪════════════════╪══════════════╪═══════════════╡
│ num.io.threads │ 10 │ The number of threads that the server uses for processing requests, w │ broker │ int │ 8 │ [1,...] │ high │ cluster-wide │
│ │ │ hich may include disk I/O │ │ │ │ │ │ │
├───────────────────────────┼────────────┼───────────────────────────────────────────────────────────────────────┼─────────┼─────────┼───────────┼────────────────┼──────────────┼───────────────┤
│ broker.id │ 1001 │ The broker id for this server. If unset, a unique broker id will be g │ broker │ int │ -1 │ │ high │ read-only │
│ │ │ enerated.To avoid conflicts between zookeeper generated broker id's a │ │ │ │ │ │ │
│ │ │ nd user configured broker id's, generated broker ids start from reser │ │ │ │ │ │ │
│ │ │ ved.broker.max.id + 1. │ │ │ │ │ │ │
├───────────────────────────┼────────────┼───────────────────────────────────────────────────────────────────────┼─────────┼─────────┼───────────┼────────────────┼──────────────┼───────────────┤
│ auto.create.topics.enable │ false │ Enable auto creation of topic on the server │ broker │ boolean │ true │ │ high │ read-only │
├───────────────────────────┼────────────┼───────────────────────────────────────────────────────────────────────┼─────────┼─────────┼───────────┼────────────────┼──────────────┼───────────────┤
│ background.threads │ 10 │ The number of threads to use for various background processing tasks │ broker │ int │ 10 │ [1,...] │ high │ cluster-wide │
╘═══════════════════════════╧════════════╧═══════════════════════════════════════════════════════════════════════╧═════════╧═════════╧═══════════╧════════════════╧══════════════╧═══════════════╛
您还可以使用-c / --config-type
标志解释生产者和消费者级别的配置。
$ cat -p producer.properties
compression.type=lz4
retries=2
$ kafkacfg explain -k 1.1 --config-type producer producer.properties | jtbl
╒══════════════════╤════════════╤═══════════════════════════════════════════════════════════════════════════════════════════════╤══════════╤════════╤═══════════╤════════════════════╤══════════════╕
│ name │ override │ description │ scope │ type │ default │ valid_values │ importance │
╞══════════════════╪════════════╪═══════════════════════════════════════════════════════════════════════════════════════════════╪══════════╪════════╪═══════════╪════════════════════╪══════════════╡
│ compression.type │ lz4 │ The compression type for all data generated by the producer. The default is none (i.e. no com │ producer │ string │ none │ │ high │
│ │ │ pression). Valid values are none, gzip, snappy, or lz4. Compression is of full batches of da │ │ │ │ │ │
│ │ │ ta, so the efficacy of batching will also impact the compression ratio (more batching means b │ │ │ │ │ │
│ │ │ etter compression). │ │ │ │ │ │
├──────────────────┼────────────┼───────────────────────────────────────────────────────────────────────────────────────────────┼──────────┼────────┼───────────┼────────────────────┼──────────────┤
│ retries │ 2 │ Setting a value greater than zero will cause the client to resend any record whose send fails │ producer │ int │ 0 │ [0,...,2147483647] │ high │
│ │ │ with a potentially transient error. Note that this retry is no different than if the client │ │ │ │ │ │
│ │ │ resent the record upon receiving the error. Allowing retries without setting max.in.flight.re │ │ │ │ │ │
│ │ │ quests.per.connection to 1 will potentially change the ordering of records because if two bat │ │ │ │ │ │
│ │ │ ches are sent to a single partition, and the first fails and is retried but the second succee │ │ │ │ │ │
│ │ │ ds, then the records in the second batch may appear first. │ │ │ │ │ │
╘══════════════════╧════════════╧═══════════════════════════════════════════════════════════════════════════════════════════════╧══════════╧════════╧═══════════╧════════════════════╧══════════════╛
kafkacfg overrides
overrides
命令将仅显示并丰富具有非默认值的配置可调整项,以帮助您了解您的Kafka配置是如何调整的。
$ kafkacfg overrides -k 3.4 samples/server.properties | jtbl
name override description scope type default valid_values importance update_mode
------------------------- ---------- ---------------------------------------------------------------------------------------------- ------- ------- --------- -------------- ------------ -------------
num.io.threads 10 The number of threads that the server uses for processing requests, which may include disk I/O broker int 8 [1,...] high cluster-wide
auto.create.topics.enable false Enable auto creation of topic on the server broker boolean true high read-only
您还可以使用-c / --config-type
标志解释生产者和消费者级别的配置覆盖。
kafkacfg query
query
命令允许您通过自定义查询过滤Kafka配置可调整项,同时丰富过滤器结果与常用元数据和可能的覆盖值。
$ kafkacfg query -v 1.1 'name=replica.fetch.min.bytes' | jtbl
name override description scope type default valid_values importance update_mode
----------------------- ---------- ---------------------------------------------------------------------------------------------------- ------- ------ --------- -------------- ------------ -------------
replica.fetch.min.bytes Minimum bytes expected for each fetch response. If not enough bytes, wait up to replicaMaxWaitTimeMs broker int 1 high read-only
您还可以组合过滤器谓词,甚至可以使用*
进行glob匹配。
$ kafkacfg query -v 3.4 "name=replica.*.bytes;importance=high" | jtbl
╒═════════════════════════════════════╤════════════╤═══════════════════════════════════════════════════╤═════════╤════════╤══════════════════════╤════════════════╤══════════════╤═══════════════╕
│ name │ override │ description │ scope │ type │ default │ valid_values │ importance │ update_mode │
╞═════════════════════════════════════╪════════════╪═══════════════════════════════════════════════════╪═════════╪════════╪══════════════════════╪════════════════╪══════════════╪═══════════════╡
│ replica.fetch.min.bytes │ │ Minimum bytes expected for each fetch response. I │ broker │ int │ 1 │ │ high │ read-only │
│ │ │ f not enough bytes, wait up to replica.fetch.wait │ │ │ │ │ │ │
│ │ │ .max.ms (broker config). │ │ │ │ │ │ │
├─────────────────────────────────────┼────────────┼───────────────────────────────────────────────────┼─────────┼────────┼──────────────────────┼────────────────┼──────────────┼───────────────┤
│ replica.socket.receive.buffer.bytes │ │ The socket receive buffer for network requests │ broker │ int │ 65536 (64 kibibytes) │ │ high │ read-only │
╘═════════════════════════════════════╧════════════╧═══════════════════════════════════════════════════╧═════════╧════════╧══════════════════════╧════════════════╧══════════════╧═══════════════╛
kafkacfg recommends
《recommends》命令基于代理属性(CPU数量、磁盘数量等)发出配置推荐。
注意:这些都是建议而非绝对真理。我们鼓励您阅读源代码,测试配置值,并形成自己的看法。
$ kafkacfg recommends -k 3.4 --broker-num-cpus 24 --broker-num-disks 12 server.properties
Recommendation 1: set num.io.threads == 12 (num_disks)
* https://strimzi.io/blog/2021/06/08/broker-tuning/
Recommendation 2: set replica.fetch.min.bytes == 512
* https://azure.microsoft.com/en-us/blog/processing-trillions-of-events-per-day-with-apache-kafka-on-azure/
Recommendation 3: set socket.receive.buffer.bytes == 512
* https://azure.microsoft.com/en-us/blog/processing-trillions-of-events-per-day-with-apache-kafka-on-azure/
* https://strimzi.io/blog/2021/06/08/broker-tuning/
Recommendation 4: set socket.send.buffer.bytes == 1048576
* https://azure.microsoft.com/en-us/blog/processing-trillions-of-events-per-day-with-apache-kafka-on-azure/
* https://strimzi.io/blog/2021/06/08/broker-tuning/
Recommendation 5: set replica.socket.receive.buffer.bytes == 1048576
* https://azure.microsoft.com/en-us/blog/processing-trillions-of-events-per-day-with-apache-kafka-on-azure/
kafkacfg diff
《diff》命令显示两个 Kafka 版本之间配置可调整项的变化,这些变化可能包括它们已被弃用、新引入或默认值已更改。
$ kafkacfg diff --from-version 3.5 --to-version 3.6 | jtbl
╒═══════════════════════════════════════════════╤══════════╤════════════════════════════════════════════════════════════╤═════════╤═════════╤════════════════════════════════════════════════════════════╤══════════════╤═══════════════╤═════════════════╤════════════════════════════════════════════════════════════╤═════════════════════════════════════╕
│ name │ status │ description │ scope │ type │ valid_values │ importance │ update_mode │ default (3.5) │ default (3.6) │ server_default_property │
╞═══════════════════════════════════════════════╪══════════╪════════════════════════════════════════════════════════════╪═════════╪═════════╪════════════════════════════════════════════════════════════╪══════════════╪═══════════════╪═════════════════╪════════════════════════════════════════════════════════════╪═════════════════════════════════════╡
│ log.local.retention.bytes │ new │ The maximum size of local log segments that can grow for a │ broker │ long │ [-2,...] │ medium │ cluster-wide │ [ABSENT] │ -2 │ │
│ │ │ partition before it gets eligible for deletion. Default v │ │ │ │ │ │ │ │ │
│ │ │ alue is -2, it represents `log.retention.bytes` value to b │ │ │ │ │ │ │ │ │
│ │ │ e used. The effective value should always be less than or │ │ │ │ │ │ │ │ │
│ │ │ equal to `log.retention.bytes` value. │ │ │ │ │ │ │ │ │
├───────────────────────────────────────────────┼──────────┼────────────────────────────────────────────────────────────┼─────────┼─────────┼────────────────────────────────────────────────────────────┼──────────────┼───────────────┼─────────────────┼────────────────────────────────────────────────────────────┼─────────────────────────────────────┤
│ log.local.retention.ms │ new │ The number of milliseconds to keep the local log segments │ broker │ long │ [-2,...] │ medium │ cluster-wide │ [ABSENT] │ -2 │ │
│ │ │ before it gets eligible for deletion. Default value is -2, │ │ │ │ │ │ │ │ │
│ │ │ it represents `log.retention.ms` value is to be used. The │ │ │ │ │ │ │ │ │
│ │ │ effective value should always be less than or equal to `l │ │ │ │ │ │ │ │ │
│ │ │ og.retention.ms` value. │ │ │ │ │ │ │ │ │
├───────────────────────────────────────────────┼──────────┼────────────────────────────────────────────────────────────┼─────────┼─────────┼────────────────────────────────────────────────────────────┼──────────────┼───────────────┼─────────────────┼────────────────────────────────────────────────────────────┼─────────────────────────────────────┤
│ log.message.timestamp.after.max.ms │ new │ This configuration sets the allowable timestamp difference │ broker │ long │ [0,...] │ medium │ cluster-wide │ [ABSENT] │ 9223372036854775807 │ │
│ │ │ between the message timestamp and the broker's timestamp. │ │ │ │ │ │ │ │ │
│ │ │ The message timestamp can be later than or equal to the b │ │ │ │ │ │ │ │ │
│ │ │ roker's timestamp, with the maximum allowable difference d │ │ │ │ │ │ │ │ │
│ │ │ etermined by the value set in this configuration. If log.m │ │ │ │ │ │ │ │ │
│ │ │ essage.timestamp.type=CreateTime, the message will be reje │ │ │ │ │ │ │ │ │
│ │ │ cted if the difference in timestamps exceeds this specifie │ │ │ │ │ │ │ │ │
│ │ │ d threshold. This configuration is ignored if log.message. │ │ │ │ │ │ │ │ │
│ │ │ timestamp.type=LogAppendTime. │ │ │ │ │ │ │ │ │
├───────────────────────────────────────────────┼──────────┼────────────────────────────────────────────────────────────┼─────────┼─────────┼────────────────────────────────────────────────────────────┼──────────────┼───────────────┼─────────────────┼────────────────────────────────────────────────────────────┼─────────────────────────────────────┤
...
您还可以通过使用《-c》/《--config-type》标志突出显示生产者和消费者级别配置的变化。
项目详情
下载文件
下载适合您平台的文件。如果您不确定选择哪个,请了解更多关于安装包的信息。
源代码分发
kafkacfg-0.7.0.tar.gz (1.2 MB 查看哈希值)
构建分发
kafkacfg-0.7.0-py3-none-any.whl (1.3 MB 查看哈希值)
关闭
kafkacfg-0.7.0.tar.gz 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 027d16c868c99c5b2b0d44b5ec46d576cfcf962141645763a337e742b5140a22 |
|
MD5 | a75362c163d3fc3b19695fda9e34a131 |
|
BLAKE2b-256 | 8e5c6b1414c29b7fde2ce751b93669f2d61dc0383b67acce80754c34f7393604 |
关闭
kafkacfg-0.7.0-py3-none-any.whl 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 3f1950687316972b64e741257f297fa82eca0cb97891250796c09333756a6f6e |
|
MD5 | aa7f8ee29dacf8617a38fc79ec740886 |
|
BLAKE2b-256 | 00b3586be56eeadb1f2163c63834b60f32734b4e0f5b8c36d91a6034013d7eb5 |