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
注意:本文归作者所有,未经作者允许,不得转载