当我们JAVA开发工程师开发一个服务或系统后,我们想监控JVM里面的各种资源情况,实现可视化和告警。可以使用prometheus+ grafana去做。
环境
系统:CentOS 7.5
软件:jmx_prometheus_javaagent-0.3.1.jar
客户端
-
下载jmx_exporter
# mkdir -p /usr/local/prometheus/jmx_exporter # cd /usr/local/prometheus/jmx_exporter # wget https://repo1.maven.org/maven2/io/prometheus/jmx/jmx_prometheus_javaagent/0.3.1/jmx_prometheus_javaagent-0.3.1.jar
-
添加配置文件
# vim /usr/local/prometheus/jmx_exporter/jmx_exporter.yml --- rules: - pattern: ".*"
-
启动jar包
# java -javaagent:/usr/local/prometheus/jmx_exporter/jmx_prometheus_javaagent-0.3.1.jar=3010:/usr/local/prometheus/jmx_exporter/jmx_exporter.yml -jar yourJar.jar
Prometheus端
-
配置Prometheus
# vim /usr/local/prometheus/prometheus.yml scrape_configs: - job_name: 'jmx' static_configs: - targets: ['10.10.10.1:3010']
-
重启Prometheus
# systemctl restart prometheus
Grafana端
- 添加dashboards
点击Create
-Import
,输入dashboards的id(推荐3457)
链接:https://www.jianshu.com/p/adada9c1f7dd