加入依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-prometheus</artifactId>
</dependency>
spring-boot 配置文件
management:
endpoints:
web:
exposure:
include: '*'
访问地址:http://127.0.0.1:1217/actuator
prometheus要采集的地址: http://127.0.0.1:1217/actuator/prometheus