1.springboot程序添加依赖项
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>io.prometheus</groupId>
<artifactId>simpleclient_spring_boot</artifactId>
<version>0.5.0</version>
</dependency>
2.程序入口增加注解
@EnablePrometheusEndpoint
@EnableSpringBootMetricsCollector
3.修改配置文件
spring.metrics.servo.enabled=false
4.运行程序,访问prometheus接口获取指标