Kafka 官方对于自身的 LAG 监控并没有太好的方法,虽然Kafka broker 自带有 kafka-topic.sh, kafka-consumer-groups.sh, kafka-console-consumer.sh 等脚本,但是对于大规模的生产集群上,使用脚本采集是非常不可靠的。


Burrow 简介

LinkedIn 公司的数据基础设施Streaming SRE团队正在积极开发Burrow,该软件由Go语言编写,在Apache许可证下发布,并托管在 GitHub Burrow上。

它收集集群消费者群组的信息,并为每个群组计算出一个单独的状态,告诉我们群组是否运行正常,是否落后,速度是否变慢或者是否已经停止工作,以此来完成对消费者状态的监控。它不需要通过监控群组的进度来获得阈值,不过用户仍然可以从中获得消息的延时数量。

Burrow 的设计框架



Burrow自动监控所有消费者和他们消费的每个分区。它通过消费特殊的内部Kafka主题来消费者偏移量。然后,Burrow将消费者信息作为与任何单个消费者分开的集中式服务提供。消费者状态通过评估滑动窗口中的消费者行为来确定。

这些信息被分解成每个分区的状态,然后转化为Consumer的单一状态。消费状态可以是OK,或处于WARNING状态(Consumer正在工作但消息消费落后),或处于ERROR状态(Consumer已停止消费或离线)。此状态可通过简单的HTTP请求发送至Burrow获取状态,也可以通过Burrow 定期检查并使用通知其通过电子邮件或单独的HTTP endpoint接口(例如监视或通知系统)发送出去。

Burrow能够监控Consumer消费消息的延迟,从而监控应用的健康状况,并且可以同时监控多个Kafka集群。用于获取关于Kafka集群和消费者的信息的HTTP上报服务与滞后状态分开,对于在无法运行Java Kafka客户端时有助于管理Kafka集群的应用程序非常有用。

Burrow 安装及版本

Burrow 是基于 Go 语言开发,当前 Burrow 的 v1.1 版本已经release。

Burrow 也提供用于 docker 镜像。

Burrow_1.2.2_checksums.txt              297 Bytes

Burrow_1.2.2_darwin_amd64.tar.gz        4.25 MB

Burrow_1.1.0_linux_amd64.tar.gz       3.22 MB (CentOS 6)

Burrow_1.2.2_linux_amd64.tar.gz        4.31 MB (CentOS 7 Require GLIBC >= 2.14)

Burrow_1.2.2_windows_amd64.tar.gz        4 MB

Source code (zip)

Source code (tar.gz)

本发行版包含针对初始1.0.0发行版中发现的问题的一些重要修复,其中包括:

  • 支持 Kafka 1.0更新版本(#306
  • Fix Zookeeper 监视处理(#328

还有一些小的功能更新

  • 存储最近的代理偏移环以避免停止的分区出现虚假警报
  • 添加可配置的通知间隔
  • 通过环境变量添加对配置的支持
  • 支持存储模块中可配置的队列深度
  1. Changelog - version 1.2
  2. [d244fce922] - Bump sarama to 1.20.1 (Vlad Gorodetsky)
  3. [793430d249] - Golang 1.9.x is no longer supported (Vlad Gorodetsky)
  4. [735fcb7c82] - Replace deprecated megacheck with staticcheck (Vlad Gorodetsky)
  5. [3d49b2588b] - Link the README to the Compose file in the project (Jordan Moore)
  6. [3a59b36d94] - Tests fixed (Mikhail Chugunkov)
  7. [6684c5e4db] - Added unit test for v3 value decoding (Mikhail Chugunkov)
  8. [10d4dc39eb] - Added v3 messages protocol support (Mikhail Chugunkov)
  9. [d6b075b781] - Replace deprecated MAINTAINER directive with a label (Vlad Gorodetsky)
  10. [52606499a6] - Refactor parseKafkaVersion to reduce method complexity (gocyclo) (Vlad Gorodetsky)
  11. [b0440f9dea] - Add gcc to build zstd (Vlad Gorodetsky)
  12. [6898a8de26] - Add libc-dev to build zstd (Vlad Gorodetsky)
  13. [b81089aada] - Add support for Kafka 2.1.0 (Vlad Gorodetsky)
  14. [cb004f9405] - Build with Go 1.11 (Vlad Gorodetsky)
  15. [679a95fb38] - Fix golint import path (golint fixer)
  16. [f88bb7d3a8] - Update docker-compose Readme section with working url. (Daniel Wojda)
  17. [3f888cdb2d] - Upgrade sarama to support Kafka 2.0.0 (#440) (daniel)
  18. [1150f6fef9] - Support linux/arm64 using Dup3() instead of Dup2() (Mpampis Kostas)
  19. [1b65b4b2f2] - Add support for Kafka 1.1.0 (#403) (Vlad Gorodetsky)
  20. [74b309fc8d] - code coverage for newly added lines (Clemens Valiente)
  21. [279c75375c] - accidentally reverted this (Clemens Valiente)
  22. [192878c69c] - gofmt (Clemens Valiente)
  23. [33bc8defcd] - make first regex test case a proper match everything (Clemens Valiente)
  24. [279b256b27] - only set whitelist / blacklist if it's not empty string (Clemens Valiente)
  25. [b48d30d18c] - naming (Clemens Valiente)
  26. [7d6c6ccb03] - variable naming (Clemens Valiente)
  27. [4e051e973f] - add tests (Clemens Valiente)
  28. [545bec66d0] - add blacklist for memory store (Clemens Valiente)
  29. [07af26d2f1] - Updated burrow endpoint in README : #401 (Ratish Ravindran)
  30. [fecab1ea88] - pass custom headers to http notifications. (#357) (vixns)
  31. Changelog - version 1.1
  32. fecab1e pass custom headers to http notifications. (#357)
  33. 7c0b8b1 Add minimum-complete config for the evaluator (#388)
  34. dc4cb84 Fix mail template (#369)
  35. e2216d7 Fetch goreleaser via curl instead of 'go get' as compilation only works in 1.10 (#387)
  36. f3659d1 Add a send-interval configuration parameter (#364)
  37. 3e488a2 Allow env vars to be used for configuration (#363)
  38. b7428c9 Fix typo in slack close (#361)
  39. 5b546cc Create the broker offset rings earlier (#360)
  40. 61f097a Metadata refresh on detecting a deleted topic must not be for that topic (#359)
  41. b890885 Make inmemory module request channel's size configurable (#352)
  42. 9911709 Update sarama to support 10.2.1 too. (#345)
  43. a1bdcde Adjusting docker build to be self-contained (#344)
  44. a91cf4d Fix an incorrect cast from #338 and add a test to cover it (#340)
  45. 389ef47 Store broker offset history (#338)
  46. 1a60efe Fix alert closing (#334)
  47. b75a6f3 Fix typo in Cluster reference
  48. cacf05e Reject offsets that are older than the group expiration time (#330)
  49. b6184ff Fix typo in the config checked for TLS no-verify #316 (#329)
  50. 3b765ea Sync Gopkg.lock with Gopkg.toml (#312)
  51. e47ec4c Fix ZK watch problem (#328)
  52. 846d785 Assume backward-compatible consumer protocol version (fix #313) (#327)
  53. e3a1493 Update sarama to support Kafka 1.0.0 (#306)
  54. 946a425 Fixing requests for StorageFetchConsumersForTopic (#310)
  55. 52e3e5d Update burrow.toml (#300)
  56. 3a4372f Upgrade sarama dependency to support Kafka 0.11.0 (#297)
  57. 8993eb7 Fix goreleaser condition (#299)
  58. d088c99 Add gitter webhook to travis config (#296)
  59. 08e9328 Merge branch 'gitter-badger-gitter-badge'
  60. 76db0a9 Fix positioning
  61. dddd0ea Add Gitter badge

安装方法可以选用源码编译,和使用官方提供的二进制包等方法。

这里推荐使用二进制包的方式。

Burrow 是无本地状态存储的,CPU密集型,网络IO密集型应用。

安装方法

  1. # wget https://github.com/linkedin/Burrow/releases/download/v1.1.0/Burrow_1.1.0_linux_amd64.tar.gz
  2. # mkdir burrow
  3. # tar -xf Burrow_1.1.0_linux_amd64.tar.gz -C burrow
  4. # cp burrow/burrow /usr/bin/
  5. # mkdir /etc/burrow
  6. # cp burrow/config/* /etc/burrow/
  7. # chkconfig --add burrow
  8. # /etc/init.d/burrow start

配置文件

  1. [general]
  2. pidfile="/var/run/burrow.pid"
  3. stdout-logfile="/var/log/burrow.log"
  4. access-control-allow-origin="mysite.example.com"
  5. [logging]
  6. filename="/var/log/burrow.log"
  7. level="info"
  8. maxsize=512
  9. maxbackups=30
  10. maxage=10
  11. use-localtime=true
  12. use-compression=true
  13. [zookeeper]
  14. servers=[ "test1.localhost:2181","test2.localhost:2181" ]
  15. timeout=6
  16. root-path="/burrow"
  17. [client-profile.prod]
  18. client-id="burrow-lagchecker"
  19. kafka-version="0.10.0"
  20. [cluster.production]
  21. class-name="kafka"
  22. servers=[ "test1.localhost:9092","test2.localhost:9092" ]
  23. client-profile="prod"
  24. topic-refresh=180
  25. offset-refresh=30
  26. [consumer.production_kafka]
  27. class-name="kafka"
  28. cluster="production"
  29. servers=[ "test1.localhost:9092","test2.localhost:9092" ]
  30. client-profile="prod"
  31. start-latest=false
  32. group-blacklist="^(console-consumer-|python-kafka-consumer-|quick-|test).*$"
  33. group-whitelist=""
  34. [consumer.production_consumer_zk]
  35. class-name="kafka_zk"
  36. cluster="production"
  37. servers=[ "test1.localhost:2181","test2.localhost:2181" ]
  38. #zookeeper-path="/"
  39. # If specified, this is the root of the Kafka cluster metadata in the Zookeeper ensemble. If not specified, the root path is used.
  40. zookeeper-timeout=30
  41. group-blacklist="^(console-consumer-|python-kafka-consumer-|quick-|test).*$"
  42. group-whitelist=""
  43. [httpserver.default]
  44. address=":8000"
  45. [storage.default]
  46. class-name="inmemory"
  47. workers=20
  48. intervals=15
  49. expire-group=604800
  50. min-distance=1
  51. #[notifier.default]
  52. #class-name="http"
  53. #url-open="http://127.0.0.1:1467/v1/event"
  54. #interval=60
  55. #timeout=5
  56. #keepalive=30
  57. #extras={ api_key="REDACTED", app="burrow", tier="STG", fabric="mydc" }
  58. #template-open="/etc/burrow/default-http-post.tmpl"
  59. #template-close="/etc/burrow/default-http-delete.tmpl"
  60. #method-close="DELETE"
  61. #send-close=false
  62. ##send-close=true
  63. #threshold=1

启动脚本(RHEL6 CentOS6):

  1. #!/bin/bash
  2. #
  3. # Comments to support chkconfig
  4. # chkconfig: - 98 02
  5. # description: Burrow is kafka lag check_program by LinkedIn, Inc.
  6. #
  7. # Source function library.
  8. . /etc/init.d/functions
  9. ### Default variables
  10. prog_name="burrow"
  11. prog_path="/usr/bin/${prog_name}"
  12. pidfile="/var/run/${prog_name}.pid"
  13. options="-config-dir /etc/burrow/"
  14. # Check if requirements are met
  15. [ -x "${prog_path}" ] || exit 1
  16. RETVAL=0
  17. start(){
  18. echo -n $"Starting $prog_name: "
  19. #pidfileofproc $prog_name
  20. #killproc $prog_path
  21. PID=$(pidofproc -p $pidfile $prog_name)
  22. #daemon $prog_path $options
  23. if [ -z $PID ]; then
  24. $prog_path $options > /dev/null 2>&1 &
  25. [ ! -e $pidfile ] && sleep 1
  26. fi
  27. [ -z $PID ] && PID=$(pidof ${prog_path})
  28. if [ -f $pidfile -a -d "/proc/$PID" ]; then
  29. #RETVAL=$?
  30. RETVAL=0
  31. #[ ! -z "${PID}" ] && echo ${PID} > ${pidfile}
  32. echo_success
  33. [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog_name
  34. else
  35. RETVAL=1
  36. echo_failure
  37. fi
  38. echo
  39. return $RETVAL
  40. }
  41. stop(){
  42. echo -n $"Shutting down $prog_name: "
  43. killproc -p ${pidfile} $prog_name
  44. RETVAL=$?
  45. echo
  46. [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$prog_name
  47. return $RETVAL
  48. }
  49. restart() {
  50. stop
  51. start
  52. }
  53. case "$1" in
  54. start)
  55. start
  56. ;;
  57. stop)
  58. stop
  59. ;;
  60. restart)
  61. restart
  62. ;;
  63. status)
  64. status $prog_path
  65. RETVAL=$?
  66. ;;
  67. *)
  68. echo $"Usage: $0 {start|stop|restart|status}"
  69. RETVAL=1
  70. esac
  71. exit $RETVAL

systemd 服务脚本(RHEL7 CentOS7):

  1. [Unit]
  2. Description=Burrow - Kafka consumer LAG Monitor
  3. After=network.target
  4. [Service]
  5. Type=simple
  6. RestartSec=20s
  7. ExecStart=/usr/bin/burrow --config-dir /etc/burrow
  8. PIDFile=/var/run/burrow/burrow.pid
  9. User=burrow
  10. Group=burrow
  11. Restart=on-abnormal
  12. [Install]
  13. WantedBy=multi-user.target

默认配置文件为 burrow.toml


使用方法

获取消费者列表

  1. GET /v3/kafka/(cluster)/consumer

Burrow 返回额接口均为 json 对象格式,所以非常方便用于二次采集处理。

获取指定消费者的状态 或 消费延时

  1. GET /v3/kafka/(cluster)/consumer/(group)/status
  2. GET /v3/kafka/(cluster)/consumer/(group)/lag

消费组健康状态的接口含义如下:

  1. NOTFOUND 消费组未找到
  2. OK 消费组状态正常
  3. WARN 消费组处在WARN状态,例如offset在移动但是Lag不停增长。 the offsets are moving but lag is increasing
  4. ERR 消费组处在ERR状态。例如,offset停止变动,但Lag非零。 the offsets have stopped for one or more partitions but lag is non-zero
  5. STOP 消费组处在ERR状态。例如offset长时间未提交。the offsets have not been committed in a log period of time
  6. STALL 消费组处在STALL状态。例如offset已提交但是没有变化,Lag非零。the offsets are being committed, but they are not changing and the lag is non-zero

获取 topic 列表

  1. GET /v3/kafka/(cluster)/topic

获取指定 topic offsets 信息

  1. GET /v3/kafka/(cluster)/topic/(topic)

Kafka 消费迟滞监控工具 Burrow的更多相关文章

  1. kafka 消费​

    前置资料  kafka kafka消费中的问题及解决方法: 情况1: 问题:脚本读取kafka 数据,写入到数据库,有时候出现MySQL server has gone away,导致脚本死掉.再次启 ...

  2. 分享一些 Kafka 消费数据的小经验

    前言 之前写过一篇<从源码分析如何优雅的使用 Kafka 生产者> ,有生产者自然也就有消费者. 建议对 Kakfa 还比较陌生的朋友可以先看看. 就我的使用经验来说,大部分情况都是处于数 ...

  3. Go语言学习之12 etcd、contex、kafka消费实例、logagent

    本节内容:    1. etcd介绍与使用    2. ElastcSearch介绍与使用 1. etcd介绍与使用    概念:高可用的分布式key-value存储,可以使用配置共享和服务发现    ...

  4. Kafka消费时报错:Producer connection to xxx:9092 unsuccessful

    使用kafka消费数据时报Producer错误,具体错误如下: kafka.producer.SyncProducer:103 Producer connection to xxx:9092 unsu ...

  5. 《Apache kafka实战》读书笔记-kafka集群监控工具

    <Apache kafka实战>读书笔记-kafka集群监控工具 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 如官网所述,Kafka使用基于yammer metric ...

  6. Kafka设计解析(十三)Kafka消费组(consumer group)

    转载自 huxihx,原文链接 Kafka消费组(consumer group) 一直以来都想写一点关于kafka consumer的东西,特别是关于新版consumer的中文资料很少.最近Kafka ...

  7. 双十一问题:kafka消费能力低下原因思考

    抛去cpu.内存等机器原因,在每个分区皆分配一个进程消费的情况下,利用扩机器来提高kafka消费速率已无能为力 此时发现,在实际洪峰时段的消费速率元达不到先前压测时的消费速率 原因思考: 1.洪峰时段 ...

  8. Kafka消费不到数据的特殊情况

    我大约是把kafka消费不到数据的特殊情况都经历了一遍了吧= =. kafka消费不到数据的原因,首先检查配置之类的,如是否设置了group.id,对应的topic是否正确等等,这些不多说. 下面是我 ...

  9. Kafka消费分组和分区分配策略

    Kafka消费分组,消息消费原理 同一个消费组里的消费者不能消费同一个分区,不同消费组的消费组可以消费同一个分区 Kafka分区分配策略 在 Kafka 内部存在两种默认的分区分配策略:Range 和 ...

随机推荐

  1. vue-cli3 取消eslint 校验代码

    项目生成后会有个.eslintrc.js文件 module.exports = { root: true, env: { node: true }, 'extends': [ 'plugin:vue/ ...

  2. CVE-2012-0158 漏洞分析报告

      Office 2003 sp3(CVE-2012-0158)漏洞分析报告   软件名称:Office 2003 sp3 软件版本:2.0 漏洞模块:MSCOMCTL.ocx 模块版本:2.0.0. ...

  3. nodejs安装 及环境变量配置教程 超详细版

    ------------恢复内容开始------------ ------------恢复内容开始------------ 上篇文件 写到  遇到了两个棘手问题  : @终端进程启动失败: shell ...

  4. 中国唯一入选 Forrester 领导者象限,阿里云 Serverless 全球领先

    3 月 26 日消息,权威咨询机构 Forrester 发布 2021 年第一季度 FaaS 平台评估报告,阿里云函数计算凭借在产品能力.安全性.战略愿景和市场规模等方面的优势脱颖而出,产品能力位列全 ...

  5. Serverless 在 SaaS 领域的最佳实践

    作者 | 计缘 来源 | Serverless 公众号 随着互联网人口红利逐渐减弱,基于流量的增长已经放缓,互联网行业迫切需要找到一片足以承载自身持续增长的新蓝海,产业互联网正是这一宏大背景下的新趋势 ...

  6. NOIP模拟76

    前言 还有不到 10 天就要 CSP-S ...马上我就要有我的第一篇游记了. 今天考试莽了一回,整了大概 2.5h 的 T1 ,可能是因为今天题目比较难,看起来成效不错. 以后还是要注意时间的分配( ...

  7. 函数返回值为 const 指针、const 引用

    函数返回值为 const 指针,可以使得外部在得到这个指针后,不能修改其指向的内容.返回值为 const 引用同理. class CString { private: char* str; publi ...

  8. Redis分布式锁的正确实现方式[转载]

    前言 分布式锁一般有三种实现方式:1. 数据库乐观锁:2. 基于Redis的分布式锁:3. 基于ZooKeeper的分布式锁.本篇博客将介绍第二种方式,基于Redis实现分布式锁.虽然网上已经有各种介 ...

  9. vue3.x组件间通信,实用小技巧都在这里

    本想简单写写,没想到说清楚已经变成了一篇很长的帖子,欢迎当笔记搜藏起来. props / emits 父子组件通信 props一般负责向子组件传递数据 下面是一个简单的例子,父组件向子组件传递了一个t ...

  10. Coursera Deep Learning笔记 改善深层神经网络:超参数调试 正则化以及梯度相关

    笔记:Andrew Ng's Deeping Learning视频 参考:https://xienaoban.github.io/posts/41302.html 参考:https://blog.cs ...