首页  

jmx_prometheus_javaagent 使用     所属分类 prometheus 浏览量 91
http://www.github.com/prometheus/jmx_exporter

yaml 配置文件 例子
https://github.com/prometheus/jmx_exporter/tree/master/example_configs


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

java -javaagent:./jmx_prometheus_javaagent-0.3.1.jar=8060:config.yaml -cp .:appdemo.jar dyyx.App
指标查看
http://127.0.0.1:8060/
http://127.0.0.1:8060/metrics

例子应用完整代码
https://gitee.com/dyyx/demos/tree/master/appdemo

JMX_EXPORT_OPTS="-javaagent:/Users/dugang/soft/tools/jmx_prometheus_javaagent-0.3.1.jar=8061:/Users/dugang/soft/tools/config.yaml"
echo $JMX_EXPORT_OPTS

javaagent 建议使用绝对路径 

Error opening zip file or JAR manifest missing : ./jmx_prometheus_javaagent-0.3.1.jar
Error occurred during initialization of VM
agent library failed to init: instrument

whitelistObjectNames 配置 ,否则只显示 jvm自带的

lowercaseOutputLabelNames: true
lowercaseOutputName: true
whitelistObjectNames: ["Catalina:*"]
blacklistObjectNames: []
rules:
 - pattern: '.*'
 
 
whitelistObjectNames: ["*:*"]
不能写成 ["*"] 会无法启动

kafka

whitelistObjectNames: 
  - "kafka.controller:type=KafkaController,name=OfflinePartitionsCount"
  - "kafka.controller:type=KafkaController,name=ActiveControllerCount"
  - "kafka.server:type=BrokerTopicMetrics,name=MessagesInPerSec"
  - "kafka.server:type=BrokerTopicMetrics,name=BytesInPerSec"
  - "kafka.server:type=ReplicaManager,name=UnderReplicatedPartitions"
  - "kafka.server:type=ReplicaFetcherManager,name=MaxLag,clientId=Replica"


whitelistObjectNames: ["org.apache.cassandra.metrics:*"]
blacklistObjectNames: ["org.apache.cassandra.metrics:type=ColumnFamily,*"]
  
bin/kafka-server-start.sh

JMX_EXPORT_OPTS="-javaagent:/Users/dugang/soft/tools/jmx_prometheus_javaagent-0.3.1.jar=8065:/Users/dugang/soft/tools/config.yaml"
echo $JMX_EXPORT_OPTS
KAFKA_OPTS="$JMX_EXPORT_OPTS $KAFKA_OPTS"
export KAFKA_OPTS="$JMX_EXPORT_OPTS $KAFKA_OPTS"
一定要 export
kafka-server-start.sh 里设置环境变量
在 kafka-run-class.sh 里 使用



startDelaySeconds: 0
hostPort: 127.0.0.1:1234
username: 
password: 
jmxUrl: service:jmx:rmi:///jndi/rmi://127.0.0.1:1234/jmxrmi
ssl: false
lowercaseOutputName: false
lowercaseOutputLabelNames: false
whitelistObjectNames: ["org.apache.cassandra.metrics:*"]
blacklistObjectNames: ["org.apache.cassandra.metrics:type=ColumnFamily,*"]
rules:
  - pattern: 'org.apache.cassandra.metrics<type=(\w+), name=(\w+)><>Value: (\d+)'
    name: cassandra_$1_$2
    value: $3
    valueFactor: 0.001
    labels: {}
    help: "Cassandra metric $1 $2"
    type: GAUGE
    attrNameSnakeCase: false




<dependency>
    <groupId>io.prometheus</groupId>
    <artifactId>jmx_prometheus_javaagent</artifactId>
    <version>0.7</version>
</dependency>	




prometheus使用jmx_exporter监控jvm prometheus node-exporter 全部指标 prometheus node-exporter 实用指标 使用node-exporter监控主机信息

上一篇     下一篇
dubbo面试题

ZooKeeper面试题

springboot 读取中文配置乱码

jmx_exporter JmxCollector 源码要点

jedis 获取 redis info 信息

Redis内部存储结构