其他分享
首页 > 其他分享> > Prometheus监控jvm

Prometheus监控jvm

作者:互联网

一、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

四、启动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:8585/

五、配置grafana模板:

https://grafana.com/grafana/dashboards/8563

选择8563这个模板.

标签:jmx,exporter,jvm,配置文件,jar,prometheus,javaagent,Prometheus,监控
来源: https://www.cnblogs.com/xjzyy/p/15737439.html