Springboot 集成 micrometer(actuator/prometheus) 报 404

百度半天也没找到原因,也可能是我搜索的方法不对。

Spring Boot 使用 Micrometer 集成 Prometheus的方案都差不多,例如 链接

按各种说明,主要2处:

1.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>
		<version>1.1.4</version>
	</dependency>

2.application.yml加

#Prometheus springboot监控配置
management:
  endpoints:
    web:
      exposure:
        include: '*'
  metrics:
    export:
      prometheus:
        enabled: true
    tags:
      application: ${spring.application.name} # 暴露的数据中添加application label

搞完后,mvn clean compile,然后debug,访问

http://localhost:8080/actuator/prometheus

提示404,一顿百度也没找到原因,最终还是google解决,原因是:

我用的springboot版本是2.3.0,对应的micrometer版本是1.5.x

改为对应版本,再mvn clean compile,访问链接就ok了

具体原因:官网文档https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-2.3-Release-Notes

同理,spring boot如果是2.4,对应micrometer版本是1.6。官方文档https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-2.4-Release-Notes

 

 

 

 

评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值