Springboot集成Prometheus

anjingsi 1年前 ⋅ 542 阅读

Springboot集成Prometheus

添加依赖pom依赖

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

application.yml

management:
  metrics:
    export:
      prometheus:
        enabled: true
  endpoints:
    prometheus:
      enabled: true
    web:
      exposure:
        include: "*"

访问

http://localhost:8080/actuator/prometheus

prometheus中prometheus.yml添加配置

scrape_configs:
  - job_name: xxxxx
    metrics_path: '/actuator/prometheus'
    static_configs:
      - targets: ['172.16.10.152:9093']
        labels:
          instance: xxx(可以与jobName一致)

模板

模板地址: https://grafana.com/grafana/dashboards/

springboot 常用的模板id:4701与10280


全部评论: 0

    我有话说: