• KafkaOffsetMonitor监控kafka


    KafkaOffsetMonitor监控kafka

    1 KafkaOffsetMonitor是一个可以用于监控Kafka的Topic及Consumer消费状况的工具,其配置和使用特别的方便。源项目Github地址为:https://github.com/quantifind/KafkaOffsetMonitor

    下载的githup上的有两种一个是源码,一种是编译好的jar包。因为编译过程需要翻墙现在一些依赖,本次用的是编译好的jar包,并且下载的jar包获取数据某些js、css需要翻墙,导致按装完成后获取不到数据。所以现在找的是一个全网通用的jar包,与kafka_2.11-0.11.0.0亲测可用,先上图:

     

     

     

    这张图片的左上角显示了当前Topic的生产速率,右上角显示了当前Consumer的消费速率。
      图片中还有三种颜色的线条,蓝色的表示当前Topic中的Message数目,灰色的表示当前Consumer消费的offset位置,红色的表示蓝色灰色的差值,即当前Consumer滞后于Producer的message数目。

    2、启动服务

     不需要配置,直接将jar包上传到服务器上并创建一个相应的目录,启动就可以。将启动过程写成一个启动脚本:

    java -cp KafkaOffsetMonitor-assembly-0.2.0.jar

        com.quantifind.kafka.offsetapp.OffsetGetterWeb

        --zk zk3:2181,zk2:2181,zk1:2181

        --port 4321

        --refresh 10.seconds

        --retain 7.days

    参数介绍以下摘自giuhup:

    • offsetStorage valid options are ”zookeeper”, ”kafka” or ”storm”. Anything else falls back to ”zookeeper”
    • zk the ZooKeeper hosts
    • port on what port will the app be available
    • refresh how often should the app refresh and store a point in the DB
    • retain how long should points be kept in the DB
    • dbName where to store the history (default ‘offsetapp’)
    • kafkaOffsetForceFromStart only applies to ”kafka” format. Force KafkaOffsetMonitor to scan the commit messages from start (see notes below)
    • stormZKOffsetBase only applies to ”storm” format. Change the offset storage base in zookeeper, default to ”/stormconsumers” (see notes below)
    • pluginsArgs additional arguments used by extensions (see below)

    使用托管服务启动,可以选用nohup、pm2等:

    # pm2 start kafka-check-monitor.sh

    关于pm2不在详细介绍。

    启动后,如果是放在内网,则需要配置代理,直接访问4321端口就可以。

    Nginx代理配置模板如下:

     1.生成密码文件      

    # htpasswd -c -d /usr/local/nginx/conf/pass_file username  

    如果想添加多个用户:

    2.添加用户     

    # htpasswd -d /usr/local/nginx/conf/pass_file username  

    #vim kafka.con

    server {

            listen *:80;

            server_name my.kafka.com;   # 请修改为你的域名

             auth_basic "it's in proteced";

             auth_basic_user_file /etc/nginx/.htpasswd;

            location / {

                    proxy_pass http://172.189.10.12:4321;

                    proxy_http_version 1.1;

                    proxy_set_header Upgrade $http_upgrade;

                    proxy_set_header Connection "upgrade";

                    proxy_set_header Host $host;

            }

    }

  • 相关阅读:
    【Codeforces Round #240 (Div. 1) 】E—Mashmokh's Designed Problem(Spaly)
    【Codeforces Round #240 (Div. 1) 】E—Mashmokh's Designed Problem(Spaly)
    拦路虎
    拦路虎:jQuery
    图片百分百问题 z-index问题
    惠头无忧——浏览器兼容性
    响应式设计
    老子的第一篇博客
    less 学习 (计划终于执行了啊,不再拖延了)
    工作拦路虎
  • 原文地址:https://www.cnblogs.com/cuishuai/p/7735409.html
Copyright © 2020-2023  润新知