有没有办法配置要使用 jmx_exporter/prometheus 捕获的 kafka-connect jmx 指标? [英] Is there a way to configure kafka-connect jmx metrics to be captured using a jmx_exporter/prometheus?
问题描述
我正在为 Kafka 生态系统中的 Kafka 连接设置监控.我已经为 kafka 代理启用了 JMX 导出器并且工作正常.现在我正在尝试为 kafka 连接启用 JMX 导出器.但是,从哪里开始有点不清楚.
I'm setting up monitoring for Kafka connect in our Kafka ecosystem. I have enabled JMX exporter for kafka brokers and is working fine. Now I am trying to enable JMX exporter for kafka connect. However, it is a bit unclear where to start.
我只能修改 connect-distributed.sh
以启用更改.任何指针都会是一个很好的补充.
I can only modify connect-distributed.sh
to enable the change. Any pointers would be a great addition.
kafka-run-class.sh
已修改,使 jmx_exporter
能够在 http://
kafka-run-class.sh
was modified to enable jmx_exporter
to emit jmx metrics on http://<host>:9304/metrics
我希望 kafka-connect 能够在 jmx_exporter
启用后在 http://<host>:19000/metrics
上发出指标.
I expect kafka-connect to emit metrics on http://<host>:19000/metrics
once the jmx_exporter
has been enabled.
推荐答案
极不推荐修改 bin
目录中的脚本.将 Kafka 升级到下一个版本时,提取新的二进制文件将覆盖在脚本中所做的更改.
Modifying a script in the bin
directory is highly unrecommended. When upgrading Kafka to the next version, extracting the new binaries would override the changes made in the script.
首选方式应该是在脚本外设置环境变量KAFKA_JMX_OPTS
:
The preferred way should be to set the environment variable KAFKA_JMX_OPTS
outside the script:
export KAFKA_JMX_OPTS="-javaagent:/opt/kafka/libs/jmx_prometheus_javaagent-0.12.0.jar=127.0.0.1:10902:/etc/kafka-connect/jmx_exporter.yaml"
export KAFKA_JMX_OPTS="-javaagent:/opt/kafka/libs/jmx_prometheus_javaagent-0.12.0.jar=127.0.0.1:10902:/etc/kafka-connect/jmx_exporter.yaml"
如果在通过脚本启动 Kafka 之前设置了 var,它将使用 var 而不是 /bin/kafka-server-start.sh
If the var is set before starting Kafka via the script it will use the var instead of the default values defined in /bin/kafka-server-start.sh
此答案由 如何为 Kafka 设置 Java 选项?
这篇关于有没有办法配置要使用 jmx_exporter/prometheus 捕获的 kafka-connect jmx 指标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!