二进制Kafka集群接入JMX_Exporter以及Kafka_exporter监控

释放双眼,带上耳机,听听看~!
🤖 由 ChatGPT 生成的文章摘要

前面介绍过了Docker-compose以及Kubernetes做Kafka的监控,接下来我们使用传统的方式接入Kafka的监控。

首先需要下载jmx_exporter的包,引用到Kafka 启动文件中

wget https://repo1.maven.org/maven2/io/prometheus/jmx/jmx_prometheus_javaagent/0.19.0/jmx_prometheus_javaagent-0.19.0.jar

#永久下载地址
wget https://d.frps.cn/file/tools/kafka/jmx_prometheus_javaagent-0.19.0.jar

Jmx exporter中包含了kafka各个组件的指标,如server metrics、producer metrics、consumer metrics等,但这些指标并不是prometheus格式的,因此需要通过重命名方式转变为prometheus格式,重命名规则配置在kafka-2_0_0.yml中

wget https://github.com/prometheus/jmx_exporter/blob/main/example_configs/kafka-2_0_0.yml

#永久下载地址
wget  https://d.frps.cn/file/tools/kafka/kafka-2_0_0.yml

编辑Kafka-run-class.sh启动脚本

...
# JMX port to use
if [  $JMX_PORT ]; then
  KAFKA_JMX_OPTS="$KAFKA_JMX_OPTS -Dcom.sun.management.jmxremote.port=$JMX_PORT "
fi
#在jmx配置参数下面添加以下环境配置

export export KAFKA_OPTS="-javaagent:/opt/kafka/bin/jmx_prometheus_javaagent-0.19.0.jar=9700:/opt/kafka/bin/kafka-2_0_0.yml"

#jmx_exporter端口为9700
#agent jar包路径都放在了/opt/kafka/bin/下

启动服务

 /opt/kafka/bin/kafka-server-start.sh -daemon /opt/kafka/config/server.properties

接下来访问9700端口就可以看到规则

jvm_threads_deadlocked 0.0
# HELP jvm_threads_deadlocked_monitor Cycles of JVM-threads that are in deadlock waiting to acquire object monitors
# TYPE jvm_threads_deadlocked_monitor gauge
jvm_threads_deadlocked_monitor 0.0
# HELP jvm_threads_state Current count of threads by state
# TYPE jvm_threads_state gauge
jvm_threads_state{state="NEW",} 0.0
jvm_threads_state{state="TERMINATED",} 0.0
jvm_threads_state{state="RUNNABLE",} 13.0
jvm_threads_state{state="BLOCKED",} 0.0
jvm_threads_state{state="WAITING",} 17.0
jvm_threads_state{state="TIMED_WAITING",} 24.0
jvm_threads_state{state="UNKNOWN",} 0.0
# HELP jmx_config_reload_success_total Number of times configuration have successfully been reloaded.
# TYPE jmx_config_reload_success_total counter
jmx_config_reload_success_total 0.0
# HELP jmx_config_reload_failure_created Number of times configuration have failed to be reloaded.
# TYPE jmx_config_reload_failure_created gauge
jmx_config_reload_failure_created 1.703144346974E9
# HELP jmx_config_reload_success_created Number of times configuration have successfully been reloaded.
# TYPE jmx_config_reload_success_created gauge
jmx_config_reload_success_created 1.703144346973E9
# HELP jvm_memory_pool_allocated_bytes_created Total bytes allocated in a given JVM memory pool. Only updated after GC, not continuously.
# TYPE jvm_memory_pool_allocated_bytes_created gauge
jvm_memory_pool_allocated_bytes_created{pool="G1 Old Gen",} 1.703144364875E9
jvm_memory_pool_allocated_bytes_created{pool="Code Cache",} 1.703144347567E9
jvm_memory_pool_allocated_bytes_created{pool="G1 Eden Space",} 1.703144347568E9
jvm_memory_pool_allocated_bytes_created{pool="G1 Survivor Space",} 1.703144347568E9
jvm_memory_pool_allocated_bytes_created{pool="Compressed Class Space",} 1.703144347568E9
jvm_memory_pool_allocated_bytes_created{pool="Metaspace",} 1.703144347568E9

Prometheus 告警

可以看下面的文章
https://i4t.com/13732.html

给TA打赏
共{{data.count}}人
人已打赏
Kafka

Kafka 安全认证SASL

2023-9-4 14:59:22

MySQL

高可用MySQL MHA介绍

2016-7-14 15:32:19

0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索