使用Prometheus和Grafana监控JVM

0

我是在windows上面安装,比较简单:

下载

https://prometheus.io/download/
https://grafana.com/grafana/download

配置Prometheus

  - job_name: "asc-gateway"
    scrape_interval: 5s
    metrics_path: '/actuator/prometheus'
    static_configs:
      - targets: ["localhost:8888"]

配置SpringBoot

依赖

<dependency>
	<groupId>org.springframework.boot</groupId>
	<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
	<groupId>io.micrometer</groupId>
	<artifactId>micrometer-registry-prometheus</artifactId>
</dependency>

端点配置

server:
  port: 8888
management:
  endpoints:
    web:
      exposure:
        include:
          - prometheus

启动

直接点击exe启动即可

http://localhost:9090/
http://localhost:3000/

配置Grafana

进入Grafana在设置里面添加Prometheus数据源

然后添加面板4701,可以看到面板数据了,如果开始数据显示N/A,需要在右上角选择时间,默认启动监控24H,所以才会没有数据显示。