监控流程
本文主要是关于Kafka Topic消费的监控,为了及时发现数据是否堆积。
本文整体的架构为:Kafka集群(Zookeeper集群保证Kafka正常运行)-->Burrow(Burrow是linkedin开源的一个监控Apache Kafka的工具)--> telegraf(Influxdb推出的收集数据的工具)-->Influxdb(TSDB,用来存储监控数据)--->grafana(展示数据)。
Burrow
安装Burrow
从github下载Burrow,以及安装
wget https://github.com/linkedin/Burrow/releases/download/v1.3.4/Burrow_1.3.4_linux_amd64.tar.gz
tar -zxvf Burrow_1.3.4_linux_amd64.tar.gz -C /home/xiaoyao
配置Burrow
修改config下的burrow.toml
[general] # 整体描述
pidfile=burrow.pid # pid文件
stdout-logfile=burrow.out # 标准输出文件名称
access-control-allow-origin=mysite.example.com # 允许跨域的地址
[logging]
filename=logs/burrow.log # 日志文件命令
level=info # 日志登记
maxsize=100 # 最大
maxbackups=30 # 开始备份的限制
maxage=10 # 最大时长
use-localtime=false #是否使用本地时间
use-compression=true # 是否使用压缩
# burrow自己用的zookeeper的配置
[zookeeper]
servers=[zookeeper0001:2181, zookeeper0002:2181, zookeeper0003:2181]
timeout=6
root-path=/burrow # 设置burrow的配置
[client-profile.burrow-test] # 设置环境,可以配置多个
client-id=burrow-test # 客户端编号
kafka-version=2.3.0 # kafka版本
# Kafka集群配置
[cluster.test]
class-name=kafka
servers=[kafka0001:9092, kafka0002:9092, kafka0003:9092]
client-profile=burrow-test # 设置环境
topic-refresh=120
offset-refresh=30
# 消费者配置
[consumer.test]
class-name=kafka
cluster=test
servers=[kafka0001:9092, kafka0002:9092, kafka0003:9092]
client-profile=burrow-test # 设置环境
group-blacklist=^(console-consumer-|python-kafka-consumer-|quick-).*$ # 设置黑名单
group-whitelist= # 设置白名单
[consumer.test_zk]
class-name=kafka_zk
cluster=test
servers=[zookeeper0001:2181, zookeeper0002:2181,zookeeper0003:2181]
zookeeper-path=/kafka-cluster
zookeeper-timeout=30
group-blacklist=^(console-consumer-|python-kafka-consumer-|quick-).*$
group-whitelist=
# http配置,设置监听端口
[httpserver.default]
address=:8000
# 设置存储配置
[storage.default]
class-name=inmemory
workers=20
intervals=15
expire-group=604800
min-distance=1
# 配置通知
[notifier.default]
class-name=http
url-open=http://someservice.example.com:1467/v1/event
interval=60
timeout=5
keepalive=30
extras={ api_key=REDACTED, app=burrow, tier=STG, fabric=mydc }
template-open=conf/default-http-post.tmpl
template-close=conf/default-http-delete.tmpl
method-close=DELETE
send-close=true
threshold=1
启动Burrow
nohup /home/xiaoyao/burrrow/burrow --config-dir /home/wocloud/burrow/config &
Telegraf
安装Telegraf
在https://github.com/influxdata/telegraf/releases,查找与自己系统匹配的telegraf
wget https://dl.influxdata.com/telegraf/releases/telegraf-1.15.3-1.x86_64.rpm
rpm -ivh telegraf-1.15.3-1.x86_64.rpm
添加配置
在/etc/telegraf/telegraf.conf 中添加新的配置
[[inputs.burrow]]
servers = ["http://localhost:8000"]
启动telegraf
systemctl restart telegraf
查看配置是否有异常数据
tail -f /var/log/telegraf/monitor.log # 这个配置是在telegraf.conf可以看到
# 如果有错误信息,可以根据错误信息进行修改
如果是在windows下,可以通过cmd中输入eventvwr.msc打开事件管理器,查看相应的错误信息,或者直接在相应的log文件查看错误信息。
如果有需要定制一些软件包的时候,可以参考我之前的博文:https://www.jianshu.com/p/a6fdf05cf222
安装 Influxdb、Grafana
由于网络中有很多关于Influx、grafana相关的博文,大家可以参考相关的配置。
需要注意的是, grafana中导入的是https://grafana.com/grafana/dashboards/10207 这个dashboard, 如果中间使用的是prometheus,可以在grafana的官网上查找相应的dashboard。
网友评论