使用 Prometheus 监控 Spring Boot 缓存指标

2024-01-28

我正在尝试使用 prometheus 来监控 spring-boot 的一些缓存指标。缓存是用以下命令创建的@Cacheable我的配置如下:

management.endpoints:
  web.exposure.include: "*"
  metrics.enabled: true
  prometheus.enabled: true
management.metrics:
  export.prometheus.enabled: true
  cache.instrument: true

我的缓存是用一个简单的方法创建的@Cacheable('mycache')- 我没有其他缓存代码或设置。我也没有使用任何特定的缓存,仅提供内置缓存。

我确实在中看到了我的缓存/actuator/caches/列表,但没有详细说明/metrics or /prometheus端点。

我的期望是一些缓存指标将发布到/actuator/metrics and /actuator/prometheus端点。

我看到了一些关于手动需要注册缓存的注释,但我也无法使其工作(我也不确定它是否真的适用)。当尝试执行此操作时,问题是我无法在CacheMetricsRegistrar豆。没有找到。


没有用于内置哈希图缓存的 Micrometer 绑定器。看https://github.com/micrometer-metrics/micrometer/tree/master/micrometer-core/src/main/java/io/micrometer/core/instrument/binder/cache https://github.com/micrometer-metrics/micrometer/tree/master/micrometer-core/src/main/java/io/micrometer/core/instrument/binder/cache用于开箱即用的实现。

这些实现自行跟踪其命中/未命中计数。由于没有任何东西在跟踪哈希图,因此没有任何东西可以显示。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

使用 Prometheus 监控 Spring Boot 缓存指标 的相关文章

随机推荐