性能測試之JVM的監控Grafana


安裝配置Grafana參考
https://testerhome.com/articles/23629

使用配置

  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有依賴,所以需全部安裝,否則不能正常使用

效果圖



掃一掃,關注我


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM