springboot actuator jvm监控丢失

1、背景

系统接入了监控prometheus和grafana,某天grafana突然发现只有几台机器可以看到指标。

随便点击一个地址http://192.168.0.76:8681/lms/actuator/prometheus访问指标,发现JVM相关指标全部丢失

2、解决方法

从网上查找相关资料,逐一排查,发现可能是组件问题、配置文件或者是依赖的版本问题。

检查git代码,没发现配置或者依赖的变动。

参考文档:https://www.choupangxia.com/2021/07/27/spring-boot-actuator-metrics-no-jvm-info/

然后在项目的启动类里注入bean就行了

复制代码
@Bean
@Lazy(value = false)
InitializingBean forcePrometheusPostProcessor(BeanPostProcessor meterRegistryPostProcessor, PrometheusMeterRegistry registry) {
	return () -> meterRegistryPostProcessor.postProcessAfterInitialization(registry, "");
}
相关推荐
q***07149 小时前
Spring Boot 多数据源解决方案:dynamic-datasource-spring-boot-starter 的奥秘(上)
java·spring boot·后端
郝开9 小时前
Spring Boot 2.7.18(最终 2.x 系列版本)8 - 日志:Log4j2 基本概念;Log4j2 多环境日志配置策略
spring boot·单元测试·log4j
q***49869 小时前
Spring Boot 3.4 正式发布,结构化日志!
java·spring boot·后端
沐浴露z11 小时前
【微服务】基本概念介绍
java·微服务
Z3r4y12 小时前
【代码审计】RuoYi-4.7.3&4.7.8 定时任务RCE 漏洞分析
java·web安全·ruoyi·代码审计
Kuo-Teng13 小时前
LeetCode 160: Intersection of Two Linked Lists
java·算法·leetcode·职场和发展
Jooou13 小时前
Spring事务实现原理深度解析:从源码到架构全面剖析
java·spring·架构·事务
dreams_dream14 小时前
Flask
后端·python·flask