linux cpu占用率如何看
562
2022-10-09
#yyds干货盘点# Prometheus Exporter(十一)Kafka Exporter
本文已经收录在 Prometheus 合集 Prometheus 都可以采集那些指标?-- 常用 Exporter 合集 中。
Kafka 是一种分布式的,基于发布 / 订阅的消息系统。原本开发自 LinkedIn,用作 LinkedIn 的活动流(Activity Stream)和运营数据处理管道(Pipeline)的基础。现在很多公司在都在使用 Kafka ,所以我找了一个 Kafka 的 Exporter 来采集 Kafka 的指标。
这个 Kafka Exporter 的地址是 ,之前作者 2 年没有更新项目,今年突然更新了。本来以为这个工具已经没人维护被弃用了,现在发现还可以继续使用。当前最新版本是 v1.4.2 ,发布于 2021.09.16 。
这个 Kafka Exporter 支持 Apache Kafka 最低版本为 v0.10.1.0 版本。
安装
Kafka Exporter 可以直接用二进制运行,也可以用 Docker 来运行。
二进制下载地址为 image 下载地址为 ,看到标签为 latest 的镜像是 17 天前推送的,也就是大约 11 月初的样子,比稳定版 v1.4.2 要晚很多,可能年底还会有一次版本更新。
启动 二进制的 命令为
kafka_exporter --kafka.server=kafka:9092 [--kafka.server=another-server ...]
注意这里是要 Cluster 的 IP地址。
启动 Docker image 的命令为
docker run -ti --rm -p 9308:9308 danielqsj/kafka-exporter:v1.4.2 --kafka.server=kafka:9092 [--kafka.server=another-server ...]
我打印了 Kafka Exporter 的帮助信息,里边有很多的参数可以使用。
[Erdong@kafka01 kafka_exporter-1.4.2.linux-amd64]$ ./kafka_exporter --help
usage: kafka_exporter [
指标
使用 这个 Exporter 可以采集以下这些类型,比如 Brokers、Topics、Consumer Groups、
关于 Brokers 主要是 Kafka 的数量。
# HELP kafka_brokers Number of Brokers in the Kafka Cluster. # TYPE kafka_brokers gauge kafka_brokers 3
关于 Topics 的指标就多了,
kafka_topic_partitions Number of partitions for this Topic kafka_topic_partition_current_offset Current Offset of a Broker at Topic/Partition kafka_topic_partition_oldest_offset Oldest Offset of a Broker at Topic/Partition kafka_topic_partition_in_sync_replica Number of In-Sync Replicas for this Topic/Partition kafka_topic_partition_leader Leader Broker ID of this Topic/Partition kafka_topic_partition_leader_is_preferred 1 if Topic/Partition is using the Preferred Broker kafka_topic_partition_replicas Number of Replicas for this Topic/Partition kafka_topic_partition_under_replicated_partition 1 if Topic/Partition is under Replicated
这些指标的输出样例如下:
# HELP kafka_topic_partitions Number of partitions for this Topic # TYPE kafka_topic_partitions gauge kafka_topic_partitions{topic="__consumer_offsets"} 50 # HELP kafka_topic_partition_current_offset Current Offset of a Broker at Topic/Partition # TYPE kafka_topic_partition_current_offset gauge kafka_topic_partition_current_offset{partition="0",topic="__consumer_offsets"} 0 # HELP kafka_topic_partition_oldest_offset Oldest Offset of a Broker at Topic/Partition # TYPE kafka_topic_partition_oldest_offset gauge kafka_topic_partition_oldest_offset{partition="0",topic="__consumer_offsets"} 0 # HELP kafka_topic_partition_in_sync_replica Number of In-Sync Replicas for this Topic/Partition # TYPE kafka_topic_partition_in_sync_replica gauge kafka_topic_partition_in_sync_replica{partition="0",topic="__consumer_offsets"} 3 # HELP kafka_topic_partition_leader Leader Broker ID of this Topic/Partition # TYPE kafka_topic_partition_leader gauge kafka_topic_partition_leader{partition="0",topic="__consumer_offsets"} 0 # HELP kafka_topic_partition_leader_is_preferred 1 if Topic/Partition is using the Preferred Broker # TYPE kafka_topic_partition_leader_is_preferred gauge kafka_topic_partition_leader_is_preferred{partition="0",topic="__consumer_offsets"} 1 # HELP kafka_topic_partition_replicas Number of Replicas for this Topic/Partition # TYPE kafka_topic_partition_replicas gauge kafka_topic_partition_replicas{partition="0",topic="__consumer_offsets"} 3 # HELP kafka_topic_partition_under_replicated_partition 1 if Topic/Partition is under Replicated # TYPE kafka_topic_partition_under_replicated_partition gauge kafka_topic_partition_under_replicated_partition{partition="0",topic="__consumer_offsets"} 0
对于 Consumer Groups 有 2 个指标,
kafka_consumergroup_current_offset Current Offset of a ConsumerGroup at Topic/Partition kafka_consumergroup_lag Current Approximate Lag of a ConsumerGroup at Topic/Partition
这两个指标的样例如下:
# HELP kafka_consumergroup_current_offset Current Offset of a ConsumerGroup at Topic/Partition # TYPE kafka_consumergroup_current_offset gauge kafka_consumergroup_current_offset{consumergroup="KMOffsetCache-kafka-manager-3806276532-ml44w",partition="0",topic="__consumer_offsets"} -1 # HELP kafka_consumergroup_lag Current Approximate Lag of a ConsumerGroup at Topic/Partition # TYPE kafka_consumergroup_lag gauge kafka_consumergroup_lag{consumergroup="KMOffsetCache-kafka-manager-3806276532-ml44w",partition="0",topic="__consumer_offsets"} 1
关于这些指标的 Grafana 展示,作者在三年前上传了一个到 Grafana Dashboards 里,我感觉已经过期了,有时间自己画一个吧。
问题排查
1. client has run out of available brokers to talk to (Is your cluster reachable?)
启动 Kafka Exporter 的时候,有时候会遇到上边的报错,这报错有多种可能,其中一种是启动的时候没有指定 Kafka 的版本,使用 --kafka.version=0.x.x.x 指定版本即可。Kafka 没有提供 version 命令,可以进入 kafka/libs 文件夹,找到像 kafka_2.10-0.8.2-beta.jar 这样的文件,其中 2.10 是 Scala 版本,0.8.2-beta 是 Kafka 版本。
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~