使用配置下载jmx_exporterhttps://github.com/prometheus/jmx_exporter创建jmx_exporter配置文件vim simple-config.yml
lowercaseOutputLabelNames: true
lowercaseOutputName: true
whitelistObjectNames: ["java.lang:type=OperatingSystem"]
blacklistObjectNames: []
rules:
- pattern: &#39;java.lang<>(committed_virtual_memory|free_physical_memory|free_swap_space|total_physical_memory|total_swap_space)_size:&#39;
name: os_$1_bytes
type: GAUGE
attrNameSnakeCase: true
- pattern: &#39;java.lang<>((?!process_cpu_time)\w&#43;):&#39;
name: os_$1
type: GAUGE
attrNameSnakeCase: true
javaagent启动应用
java -javaagent:./jmx_prometheus_javaagent-0.14.0.jar&#61;8080:simple-config.yaml -jar yourJar.jar在prometheus配置文件中添加配置scrape_configs:
- job_name: &#39;java&#39;
static_configs:
- targets: [&#39;:&#39;]重启prometheusnohup ./prometheus > prometheus.log 2>&1 &下载并导入dashboardshttps://grafana.com/grafana/dashboards/7727
https://grafana.com/grafana/dashboards/8563
注&#xff1a;8563模板对7727有依赖&#xff0c;所以需全部安装&#xff0c;否则不能正常使用
效果图
![e0f76972bd393f7f73bb55a5cbb43c43.png](https://img.php1.cn/3cd4a/1eebe/cd5/d34245582687a4e6.webp)
![db68c9575d4b52de500e37dea63c862c.png](https://img.php1.cn/3cd4a/1eebe/cd5/99b88427bc9ce0dc.webp)
扫一扫&#xff0c;关注我