配置jmx exporter
cd /usr/local/
创建目录:mkdir jmx_exporter
进入目录:cd jmx_exporter
网盘下载jmx_prometheus_javaagent-0.12.0.jar,放到jmx_exporter目录
jmx_exporter目录下创建jmx_exporter.yml:vim /usr/local/prometheus/jmx_exporter/jmx_exporter.yml
内容如下:
--- lowercaseOutputLabelNames: true lowercaseOutputName: true whitelistObjectNames: ["java.lang:type=OperatingSystem"] rules: - pattern: 'java.lang<type=OperatingSystem><>((?!process_cpu_time)\w+):' name: os_$1 type: GAUGE attrNameSnakeCase: true
启动项目:
java -javaagent:/usr/local/jmx_exporter/jmx_prometheus_javaagent-0.12.0.jar=3010:/usr/local/jmx_exporter/jmx_exporter.yml -jar gift-0.0.1-SNAPSHO.jar
访问exporter:http://192.168.117.180:3010/
搜索“jvm_memory_bytes_max”能搜索到数据
配置prometheus
(安装prometheus参考之前搭建linux监控的思维导图)
修改配置文件,增加一个job_name:vim prometheus.yml
- job_name: 'jmx' static_configs: - targets: ['192.168.117.180:3010'] labels: instance: jmx_exporter
重启prometheus:systemctl restart prometheus
访问:http://192.168.117.180:9090/
搜索:jvm_memory_bytes_max
配置grafana
(安装grafana参考之前搭建jmeter监控的思维导图)
点击import,导入Dashboard
job要填写prometheus.yml里的job_name
结果
最后打开刚刚导入的Dashboard,如下图