小知识,大挑战!本文正在参与“程序员必备小知识”创作活动。
前言
无意中看到一个Go写的kafka消费组延迟检查的小工具(Burrow),当然还带了一些其他小功能
官网地址: github.com/linkedin/Bu…
特色介绍:
- 支持多kafka集群
- 支持查看topic详情
- 支持查看消费组和消费组状态、延迟
- 支持emailer和http方式通知
- 提供http api请求访问和返回json数据格式
安装
直接下载官网提供的包,没有必要去搞环境打包: github.com/linkedin/Bu… 根据自已的系统下载
下载
#下载
wget https://github.com/linkedin/Burrow/releases/download/v1.3.6/Burrow_1.3.6_linux_amd64.tar.gz
#创建目录
mkdir ktool
#解压包
mv Burrow_1.3.6_linux_amd64.tar.gz ktool
tar xf Burrow_1.3.6_linux_amd64.tar.gz
配置
修改配置文件内容
#将目录改一名,因为代码默认读取conf目录
mv config conf
cd conf
配置如下,将ip{1-3} 换成自已的zk,kafka的ip
vim conf/burrow.toml
[general]
pidfile="burrow.pid"
stdout-logfile="burrow.out"
access-control-allow-origin="*"
[logging]
filename="logs/burrow.log"
level="info"
maxsize=100
maxbackups=30
maxage=10
use-localtime=false
use-compression=true
[zookeeper]
servers=[ "ip1:2181" ]
timeout=6
root-path="/burrow"
[client-profile.test]
client-id="burrow-test"
kafka-version="0.10.0"
[cluster.local]
class-name="kafka"
servers=[ "ip1:9092", "ip2:9092", "ip3:9092" ]
client-profile="test"
topic-refresh=120
offset-refresh=30
[consumer.local]
class-name="kafka"
cluster="local"
servers=[ "ip1:9092", "ip2:9092", "ip3:9092" ]
client-profile="test"
group-denylist="^(console-consumer-|python-kafka-consumer-|quick-).*$"
group-allowlist=""
[consumer.local_zk]
class-name="kafka_zk"
cluster="local"
servers=[ "ip1:2181" ]
zookeeper-path="/kafka-cluster"
zookeeper-timeout=30
group-denylist="^(console-consumer-|python-kafka-consumer-|quick-).*$"
group-allowlist=""
[httpserver.default]
address=":8000"
[storage.default]
class-name="inmemory"
workers=20
intervals=15
expire-group=604800
min-distance=1
启动
启动命令
cd ktool
./burrow -config-dir conf
如时显示了 Reading configuration from conf 然后一直卡住,说明启动成功
使用
因该项目只有接口,没有UI界面,访问方式就是请求http api接口,返回kafka相关json数据信息
wiki文档: github.com/linkedin/Bu…
在linux服务器安装一个jq(命令行json解析工具),然后来访问测试
查看所有topic
curl -s http://127.0.0.1:8000/v3/kafka/local/topic | jq .
查看所有消费组
curl -s http://127.0.0.1:8000/v3/kafka/local/consumer | jq .
查看topic详情 topic名字为maxwell
curl -s http://127.0.0.1:8000/v3/kafka/local/topic/maxwell | jq .
查看某个消费组详情 消费组名字为maxwell_test1
curl -s http://127.0.0.1:8000/v3/kafka/local/consumer/maxwell_test1 | jq .
可以看到该maxwell有5个分区,目前第3分区有11110个消息 (分区是0,1,2,3,4 所以看上去像第4分区)
查看某个消费组滞后
curl -s http://127.0.0.1:8000/v3/kafka/local/consumer/maxwell_test1/lag | jq .
- maxwell_test1消费组 总的延迟为9062
- 最新消费到offset为1990
- 目前消费组的状态是停止的
- 该消费组订阅的topic是maxwell
总结
作为一个查看消费组详情的小工具来说,还是挺给力的