Prometheus+Grafana+jmx_exporter 监控 Java 虚拟机
Prometheus Grafana DevOps About 1,513 wordsagent 下载地址
https://github.com/prometheus/jmx_exporter/releases
配置文件样例
https://github.com/prometheus/jmx_exporter/tree/master/example_configs
配置文件
此配置文件Grafana Dashboard 8563
中提供。
---
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
启动 jar
-javaagent
配置代理,并指定端口和配置文件。
nohup java -javaagent:./jmx_prometheus_javaagent-0.16.1.jar=18080:sample_config.yml -jar demo.jar > demo.out 2>&1 &
修改 Prometheus 配置
scrape_configs
下新增job_name
为java
(名称随意)
- job_name: 'java'
static_configs:
- targets: ['192.168.0.100:18080']
完整的scrape_configs
如下
scrape_configs:
- job_name: "prometheus"
static_configs:
- targets: ["localhost:9090"]
- job_name: 'java'
static_configs:
- targets: ['192.168.0.100:18080']
重启 Prometheus
重启后可查看jmx_exporter
是否上线。
Grafana Dashboard
JVM dashboard: https://grafana.com/grafana/dashboards/8563
注意
Grafana Dashboard 8563
中默认的job_name
为java
,如果在prometheus.yml
配置的jmx_exporter
不为java
,可以更改Grafana
导入时的job
名称。
开源地址
Views: 2,340 · Posted: 2022-02-23
————        END        ————
Give me a Star, Thanks:)
https://github.com/fendoudebb/LiteNote扫描下方二维码关注公众号和小程序↓↓↓
Loading...