Prometheus+Grafana可视化监控SpringBoot项目

添加Pom依赖

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
</dependency>
<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: 8010
spring:
  application:
    name: spring-boot-prometheus-grafana

management:
  endpoints:
    web:
      exposure:
        include: "*"
  endpoint:
    health:
      show-details: always

访问测试:http://localhost:8080/actuator/prometheus

添加Job

进入Prometheus安装根目录 vim prometheus.yml
新增节点

  - job_name: 'spring_boot_8010'
    metrics_path: /actuator/prometheus
    static_configs:
    - targets: ['127.0.0.1:8010']

job_name:任务名称
metrics_path: 指标路径
targets:实例地址/项目地址,可配置多个

启动prometheus

在Grafana中添加模版id:4701

模版地址:https://grafana.com/grafana/dashboards/4701


posted @ 2021-02-24 21:47  dkn  阅读(356)  评论(0编辑  收藏  举报