1.jmx github地址
GitHub - prometheus/jmx_exporter: A process for exposing JMX Beans via HTTP for Prometheus consumption
wget https://repo1.maven.org/maven2/io/prometheus/jmx/jmx_prometheus_javaagent/0.16.1/jmx_prometheus_javaagent-0.16.1.jar
2.jmx config
-
可以通过java.lang 采集机器cpu 内存等基础信息
-
https://github.com/prometheus/jmx_exporter/tree/master/example_configs
cat <<"EOF" > common.yaml
---
lowercaseOutputLabelNames: true
lowercaseOutputName: true
whitelistObjectNames: ["java.lang:type=OperatingSystem"]
blacklistObjectNames: []
rules:
- pattern: 'java.lang<type=OperatingSystem><>(committed_virtual_memory|free_physical_memory|free_swap_space|total_physical_memory|total_swap_space)_size:'
name: os_$1_bytes
type: GAUGE
attrNameSnakeCase: true
- pattern: 'java.lang<type=OperatingSystem><>((?!process_cpu_time)\w+):'
name: os_$1
type: GAUGE
attrNameSnakeCase: true
EOF
3.自行下载安装好kafka和zk,这里不赘述
4.修改zookeeper 启动脚本
-
修改zookeeper 添加jmx_exporter.jar启动
-
在bin/zookeeper-server-start.sh 脚本EXTRA_ARGS 下面添加 EXTRA_ARGS
#
# EXTRA_ARGS=${EXTRA_ARGS-'-name zookeeper -loggc'}export EXTRA_ARGS="$EXTRA_ARGS -javaagent:/opt/app/jmx_exporter/jmx_prometheus_javaagent-0.16.0.jar=9142:/opt/app/jmx_exporter/common.yaml"
文章来源地址https://www.toymoban.com/news/detail-827421.html
5.启动zk
-
使用安装包中的脚本启动单节点 Zookeeper 实例:
bin/kafka-run-class.sh +289 CONSOLE_OUTPUT_FILE可能报找不到,赋个别的值就可以了
bin/zookeeper-server-start.sh -daemon config/zookeeper.properties
6.检查zk
-
zookeeper启动应该listen 2181和9142端口
-
ss -ntlp |grep java
7.修改kafka启动脚本, 添加jmx_exporter.jar启动
-
在bin/kafka-server-start.sh 脚本最上面添加下面这行
-
export KAFKA_OPTS="-javaagent:/opt/app/jmx_exporter/jmx_prometheus_javaagent-0.16.1.jar=9309:/opt/app/jmx_exporter/kafka-agent.yaml"
8.启动kafka
-
使用 kafka-server-start.sh 启动 kafka 服务:
-
bin/kafka-server-start.sh -daemon config/server.properties文章来源:https://www.toymoban.com/news/detail-827421.html
到了这里,关于jmx_exporter监控kafka和zk的jvm的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!