一、GitHub主页:
https://github.com/prometheus/jmx_exporter
https://repo1.maven.org/maven2/io/prometheus/jmx/jmx_prometheus_javaagent/0.14.0/jmx_prometheus_javaagent-0.14.0.jar
下载jmx_prometheus_javaagent-0.14.0.jar
二、新增jmx_exporter配置文件:
vim jmx_exporter_config.yaml
# 新增jmx_exporter配置文件
---
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
三、编辑prometheus配置文件:
vim prometheus/prometheus.yml
# 编辑prometheus配置文件
新增job
- job_name: 'jmx_exporter'
static_configs:
- targets: ['192.168.1.113:8585']
labels:
instance: jmx_exporter
docker restart prometheus2020
重启容器
firewall-cmd --zone=public --add-port=8585/tcp --permanent
firewall-cmd --reload
# 开放防火墙8585端口
四、启动jmx_exporter
java -javaagent:./jmx_prometheus_javaagent-0.14.0.jar=8585:jmx_exporter_config.yaml -jar demo-0.0.1-SNAPSHOT.jar
# jmx_exporter并暴露8585端口并加载配置文件
访问
http://192.168.1.113:9090/targets
访问
http://192.168.1.113:8585/
五、配置grafana模板:
https://grafana.com/grafana/dashboards/8563
选择8563这个模板