Apache Kafka监控之Kafka Web Console
Kafka Web Console:是一款开源的系统,源码的地址在https://github.com/claudemamo/kafka-web-console中。Kafka Web Console也是用Scala语言编写的Java web程序用于监控Apache Kafka。这个系统的功能和KafkaOffsetMonitor很类似,但是我们从源码角度来看,这款系统实现比KafkaOffsetMonitor要复杂很多,而且编译配置比KafkaOffsetMonitor较麻烦。
要想运行这套系统我们需要的先行条件为:
- Play Framework 2.2.x
- Apache Kafka 0.8.x
- Zookeeper 3.3.3 or 3.3.4
同样,我们从https://github.com/claudemamo/kafka-web-console上面将源码下载下来,然后用sbt进行编译,在编译前我们需要做如下的修改:
1、Kafka Web Console默认用的数据库是H2,它支持以下几种数据库:
- H2 (default)
- PostgreSql
- Oracle
- DB2
- MySQL
- ApacheDerby
- Microsoft SQL Server
- #############################################################################
- User:过往记忆
- Date:14-08-08
- Time:11:37
- bolg: https://www.iteblog.com
- 本文地址:https://www.iteblog.com/archives/1084
- 过往记忆博客,专注于hadoop、hive、spark、shark、flume的技术博客,大量的干货
- 过往记忆博客微信公共帐号:iteblog_hadoop
- #############################################################################
- 将这个
- db.default.driver=org.h2.Driver
- db.default.url="jdbc:h2:file:play"
- # db.default.user=sa
- # db.default.password=""
- 修改成
- db.default.driver=com.mysql.jdbc.Driver
- db.default.url="jdbc:mysql://localhost:3306/test"
- db.default.user=root
- db.default.pass=123456
- "mysql"%"mysql-connector-java"%"5.1.31"
修改后的bulid.sbt :
- name := "kafka-web-console"
- version := "2.1.0-SNAPSHOT"
- libraryDependencies ++= Seq(
- jdbc,
- cache,
- "org.squeryl" % "squeryl_2.10" % "0.9.5-6",
- "com.twitter" % "util-zk_2.10" % "6.11.0",
- "com.twitter" % "finagle-core_2.10" % "6.15.0",
- "org.quartz-scheduler" % "quartz" % "2.2.1",
- "org.apache.kafka" % "kafka_2.10" % "0.8.1.1",
- "mysql" % "mysql-connector-java" % "5.1.31"
- exclude("javax.jms", "jms")
- exclude("com.sun.jdmk", "jmxtools")
- exclude("com.sun.jmx", "jmxri")
- )
- play.Project.playScalaSettings
2、执行conf/evolutions/default/bak目录下面的1.sql、2.sql和3.sql三个文件。需要注意的是,这三个sql文件不能直接运行,有语法错误,需要做一些修改。
修改后的1.sql :
- CREATE TABLE zookeepers (
- name VARCHAR(100),
- host VARCHAR(100),
- port INT(100),
- statusId INT(100),
- groupId INT(100),
- PRIMARY KEY (name)
- );
- CREATE TABLE groups (
- id INT(100),
- name VARCHAR(100),
- PRIMARY KEY (id)
- );
- CREATE TABLE status (
- id INT(100),
- name VARCHAR(100),
- PRIMARY KEY (id)
- );
- INSERT INTO groups (id, name) VALUES (0, 'ALL');
- INSERT INTO groups (id, name) VALUES (1, 'DEVELOPMENT');
- INSERT INTO groups (id, name) VALUES (2, 'PRODUCTION');
- INSERT INTO groups (id, name) VALUES (3, 'STAGING');
- INSERT INTO groups (id, name) VALUES (4, 'TEST');
- INSERT INTO status (id, name) VALUES (0, 'CONNECTING');
- INSERT INTO status (id, name) VALUES (1, 'CONNECTED');
- INSERT INTO status (id, name) VALUES (2, 'DISCONNECTED');
- INSERT INTO status (id, name) VALUES (3, 'DELETED');
修改后的2.sql :
- ALTER TABLE zookeepers ADD COLUMN chroot VARCHAR(100);
修改后的3.sql :
- ALTER TABLE zookeepers DROP PRIMARY KEY;
- ALTER TABLE zookeepers ADD COLUMN id int(100) NOT NULL AUTO_INCREMENT PRIMARY KEY;
- ALTER TABLE zookeepers MODIFY COLUMN name VARCHAR(100) NOT NULL;
- ALTER TABLE zookeepers MODIFY COLUMN host VARCHAR(100) NOT NULL;
- ALTER TABLE zookeepers MODIFY COLUMN port INT(100) NOT NULL;
- ALTER TABLE zookeepers MODIFY COLUMN statusId INT(100) NOT NULL;
- ALTER TABLE zookeepers MODIFY COLUMN groupId INT(100) NOT NULL;
- ALTER TABLE zookeepers ADD UNIQUE (name);
- CREATE TABLE offsetHistory (
- id int(100) AUTO_INCREMENT PRIMARY KEY,
- zookeeperId int(100),
- topic VARCHAR(255),
- FOREIGN KEY (zookeeperId) REFERENCES zookeepers(id),
- UNIQUE (zookeeperId, topic)
- );
- CREATE TABLE offsetPoints (
- id int(100) AUTO_INCREMENT PRIMARY KEY,
- consumerGroup VARCHAR(255),
- timestamp TIMESTAMP,
- offsetHistoryId int(100),
- partition int(100),
- offset int(100),
- logSize int(100),
- FOREIGN KEY (offsetHistoryId) REFERENCES offsetHistory(id)
- );
- CREATE TABLE settings (
- key_ VARCHAR(255) PRIMARY KEY,
- value VARCHAR(255)
- );
- INSERT INTO settings (key_, value) VALUES ('PURGE_SCHEDULE', '0 0 0 ? * SUN *');
- INSERT INTO settings (key_, value) VALUES ('OFFSET_FETCH_INTERVAL', '30');
project/build.properties的
sbt.version=0.13.0 要修改实际的sbt版本,比如我用的是sbt.version=0.13.15
上面的注意事项弄完之后,我们就可以编译下载过来的源码:
# sbt package |
编译的过程比较慢,有些依赖包下载速度非常地慢,请耐心等待。
- [warn]modulenot found: com.typesafe.play#sbt-plugin;2.2.1
- [warn]==== typesafe-ivy-releases: tried
- [warn] http://repo.typesafe.com/typesafe/ivy-releases/
- com.typesafe.play/sbt-plugin/scala_2.9.2/sbt_0.12/2.2.1/ivys/ivy.xml
- [warn]==== sbt-plugin-releases: tried
- [warn] http://scalasbt.artifactoryonline.com/scalasbt/sbt-plugin-releases/
- com.typesafe.play/sbt-plugin/scala_2.9.2/sbt_0.12/2.2.1/ivys/ivy.xml
- [warn]====local: tried
- [warn]/home/iteblog/.ivy2/local/com.typesafe.play/
- sbt-plugin/scala_2.9.2/sbt_0.12/2.2.1/ivys/ivy.xml
- [warn]====Typesafe repository: tried
- [warn] http://repo.typesafe.com/typesafe/releases/com/
- typesafe/play/sbt-plugin_2.9.2_0.12/2.2.1/sbt-plugin-2.2.1.pom
- [warn]====public: tried
- [warn] http://repo1.maven.org/maven2/com/typesafe/play/
- sbt-plugin_2.9.2_0.12/2.2.1/sbt-plugin-2.2.1.pom
- [warn]::::::::::::::::::::::::::::::::::::::::::::::
- ====local: tried
- /home/iteblog/.ivy2/local/org.scala-sbt/collections/0.13.0/jars/collections.jar
- ::::::::::::::::::::::::::::::::::::::::::::::
- :: FAILED DOWNLOADS ::
- ::^ see resolution messages for details ^::
- ::::::::::::::::::::::::::::::::::::::::::::::
- :: org.scala-sbt#collections;0.13.0!collections.jar
- ::::::::::::::::::::::::::::::::::::::::::::::
启动的时候需要把.sql文件删除掉,否则会报错。
http://localhost:9000
最后,我们可以通过下面命令启动Kafka Web Console监控系统:
# sbt run |
并可以在http://localhost:9000查看。下面是一张效果图
Before you can monitor a broker, you need to register the Zookeeper server associated with it:
Kafka Web Console
Kafka Web Console is a Java web application for monitoring Apache
Kafka. With a modern web
browser, you can view from the console:
- Registered brokers

- Topics, partitions, log sizes, and partition leaders

- Consumer groups, individual consumers, consumer owners, partition offsets and lag

- Graphs showing consumer offset and lag history as well as consumer/producer message throughput history.

- Latest published topic messages (requires web browser support for WebSocket)

Furthermore, the console provides a JSON API described in RAML.
The API can be tested using the embedded API Console accessible through the URL http://[hostname]:[port]/api/console.
Requirements
- Play Framework 2.2.x
- Apache Kafka 0.8.x
- Zookeeper 3.3.3 or 3.3.4
Deployment
Consult Play!'s documentation for deployment
options and instructions.
Getting
Started
Kafka Web Console requires a relational database. By default, the server connects to an embedded H2 database and no database installation or configuration is needed. Consult Play!'s documentation to specify
a database for the console. The following databases are supported:- H2 (default)
- PostgreSql
- Oracle
- DB2
- MySQL
- Apache Derby
- Microsoft SQL Server
Changing the database might necessitate making minor modifications to the DDL to
accommodate the new database.Before you can monitor a broker, you need to register the Zookeeper server associated with it:

Filling in the form and clicking on Connect will
register the Zookeeper server. Once the console has successfully established a connection with the registered Zookeeper server, it can retrieve all necessary information about brokers, topics, and consumers:

Apache Kafka监控之Kafka Web Console的更多相关文章
- 【转载】Apache Kafka监控之Kafka Web Console
http://www.iteblog.com/archives/1084 Kafka Web Console是一款开源的系统,源码的地址在https://github.com/claudemamo/k ...
- Kafka监控系统Kafka Eagle剖析
1.概述 最近有同学留言反馈了使用Kafka监控工具Kafka Eagle的一些问题,这里笔者特意整理了这些问题.并且希望通过这篇博客来解答这些同学的在使用Kafka Eagle的时候遇到的一些困惑, ...
- Kafka监控系统Kafka Eagle:支持kerberos认证
在线文档:https://ke.smartloli.org/ 作者博客:https://www.cnblogs.com/smartloli/p/9371904.html 源码地址:https://gi ...
- 【转】apache kafka监控系列-KafkaOffsetMonitor
apache kafka监控系列-KafkaOffsetMonitor 时间 2014-05-27 18:15:01 CSDN博客 原文 http://blog.csdn.net/lizhitao ...
- apache kafka监控系列-KafkaOffsetMonitor(转)
原文链接:apache kafka监控系列-KafkaOffsetMonitor 概览 最 近kafka server消息服务上线了,基于jmx指标参数也写到zabbix中了,但总觉得缺少点什么东西, ...
- apache kafka监控系列-KafkaOffsetMonitor
apache kafka中国社区QQ群:162272557 概览 近期kafka server消息服务上线了,基于jmx指标參数也写到zabbix中了.但总认为缺少点什么东西.可视化可操作的界面. z ...
- DataPipeline |《Apache Kafka实战》作者胡夕:Apache Kafka监控与调优
胡夕 <Apache Kafka实战>作者,北航计算机硕士毕业,现任某互金公司计算平台总监,曾就职于IBM.搜狗.微博等公司.国内活跃的Kafka代码贡献者. 前言 虽然目前Apache ...
- DataPipeline |ApacheKafka实战作者胡夕:Apache Kafka监控与调优
https://baijiahao.baidu.com/s?id=1610644333184173190&wfr=spider&for=pc DataPipeline |ApacheK ...
- kafka监控系统
Metrics-Java版的指标度量工具之一 Metrics-Java版的指标度量工具之二 JAVA Metrics 度量工具使用介绍1 JAVA Metrics度量工具 - Metrics Core ...
随机推荐
- [转]ZooKeeper 集群环境搭建 (本机3个节点)
ZooKeeper 集群环境搭建 (本机3个节点) 是一个简单的分布式同步数据库(或者是小文件系统) ------------------------------------------------- ...
- Java匿名内部类的继承者、终结者————lambda表达式
一.什么是lambda表达式? lambda表达式就是一个代码块,可以传入变量和放入相应的代码. 二.基本格式 (参数 ) - >{ 代码 ...
- ace编辑器 光标错位
字体的关系
- 常用cursor光标说明
1.cursor语法: cursor : auto | crosshair | default | hand | move | help | wait | text | w-resize |s-res ...
- day 017面向对象-反射
主要内容: isinstance, type, issubclass( 内置函数) 区分函数和方法 反射 一 ( isinstance, type, issubclass) isinstance ...
- 杜教BM
#include <algorithm> #include <iterator> #include <iostream> #include <cstring& ...
- ionic打包步骤(安卓)
打包APP之前要做的工作: ionic resources -icon : [创建一个app图标]: 以png/psd/AI格式保存在项目目录下的:resource/android/icon.png ...
- hashCode()方法 和 hash()方法
String str = "abc"; String str1 = "abc"; System.out.println(str == str1); //true ...
- 依赖注入的方式测试ArrayList和LinkedList的效率(对依赖注入的再次理解)
9/20 号再进行学习 在C++中,main函数尽可能的简单,只要调用子函数的一句话就实现了功能. java开发中,controller就相同于是main函数,其他类的方法不在本类中时候, 1.可以用 ...
- 梯度下降与pytorch
记得在tensorflow的入门里,介绍梯度下降算法的有效性时使用的例子求一个二次曲线的最小值. 这里使用pytorch复现如下: 1.手动计算导数,按照梯度下降计算 import torch #使用 ...