关于java:性能测试之JVM的监控Grafana

36次阅读

共计 982 个字符,预计需要花费 3 分钟才能阅读完成。

装置配置 Grafana 参考
https://testerhome.com/articl…

应用配置

  1. 下载 jmx_exporter
https://github.com/prometheus/jmx_exporter
  1. 创立 jmx_exporter 配置文件
vim simple-config.yml

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

javaagent 启动利用
java -javaagent:./jmx_prometheus_javaagent-0.14.0.jar=8080:simple-config.yaml -jar yourJar.jar

  1. 在 prometheus 配置文件中增加配置
scrape_configs:
  - job_name: 'java'
    static_configs:
    - targets: ['<host>:<port>']
  1. 重启 prometheus
nohup ./prometheus  > prometheus.log 2>&1 &
  1. 下载并导入 dashboards
https://grafana.com/grafana/dashboards/7727
https://grafana.com/grafana/dashboards/8563
注:8563 模板对 7727 有依赖,所以需全副装置,否则不能失常应用 

效果图



扫一扫,关注我

正文完
 0