kafka_exporter 经过 Kafka Protocol Specification 收集 Brokers, Topics 以及 Consumer Groups的相关指标,使用简单,运行高效,相比于以往经过kafka内置的脚本进行收集,因为没有了JVM的运行开销,指标收集时间从分钟级别降到秒级别,便于大规模集群的监控。linux
git项目地址:https://github.com/danielqsj/kafka_exportergit
下载地址: https://github.com/danielqsj/kafka_exporter/releases/download/v1.2.0/kafka_exporter-1.2.0.linux-amd64.tar.gzgithub
docker安装略过docker
grafana安装apache
#docker run -d --name=grafana -v /etc/localtime:/etc/localtime:ro --restart=always -p 3000:3000 grafana/grafana |
prometheus启动vim
#docker run -d --name=prometheus -p 9090:9090 --restart=always -v /etc/localtime:/etc/localtime:ro -v /home/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml prom/prometheus |
注:提早将须要挂载的目录建立好浏览器
#mkdir -pv /home/prometheus/ |
登录到kafka服务器下载kafka_exporter
ide
# tar -zxvf kafka_exporter-1.2.0.linux-amd64.tar.gz # cd kafka_exporter-1.2.0.linux-amd64 # ./kafka_exporter --kafka.server=kafkaIP或者域名:9092 & #ss -tunl |
注:9308是kafka_exporter的端口
登录到prometheus服务器
编写/home/prometheus/prometheus.yml文件
#vim /home/prometheus/prometheus.yml scrape_configs: # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config. - job_name: 'prometheus' static_configs: - targets: ['localhost:9090']
- job_name: 'kafka' static_configs: - targets: ['kafkaIP或者域名:9308'] labels: instance: kafka@kafkaIP或者域名 |
重启prometheus
#docker restart prometheus |
经过浏览器访问:http://prometheus服务器IP:9090,所添加的kafka_exporter状态为UP,就能够去配置grafana
配置grafana
经过浏览器访问:http://grafana服务器IP:3000,
添加数据源,选择prometheus,填入prometheus服务器IP端口,点击保存
导入监控图表
输入7589,光标往下移,以下图
图表数据就出来了