Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/spring-boot/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/silverlight/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring boot 如何使用RedisCacheManager公开Prometheus度量?_Spring Boot_Metrics_Redis Cache - Fatal编程技术网

Spring boot 如何使用RedisCacheManager公开Prometheus度量?

Spring boot 如何使用RedisCacheManager公开Prometheus度量?,spring-boot,metrics,redis-cache,Spring Boot,Metrics,Redis Cache,我有一个SpringBoot2应用程序,它已经实现了带有caffee缓存管理器的缓存。缓存是通过@Cacheable,@cacheexecute,@CachePut注释以标准方式实现的 我迁移了这个应用程序,使用Redis在pod之间分配缓存 现在的问题在于指标。在迁移之前,caffee公开了缓存度量,比如cache\u put\u total,cache\u get\u total,等等,现在什么都没有了。RedisCacheManager中是否实现了度量标准?我什么也找不到 不幸的是,正如您

我有一个SpringBoot2应用程序,它已经实现了带有
caffee
缓存管理器的缓存。缓存是通过
@Cacheable
@cacheexecute
@CachePut
注释以标准方式实现的

我迁移了这个应用程序,使用
Redis
在pod之间分配缓存


现在的问题在于指标。在迁移之前,
caffee
公开了缓存度量,比如
cache\u put\u total
cache\u get\u total
,等等,现在什么都没有了。
RedisCacheManager
中是否实现了度量标准?我什么也找不到

不幸的是,正如您在Spring Boot文档中所看到的:,Spring Boot默认情况下不提供Redis的缓存统计信息:

默认情况下,Spring Boot为EhCache、Hazelcast、Infinispan、JCache和Guava提供缓存统计信息。如果您喜爱的缓存库不支持开箱即用,则可以添加其他CacheStatisticsProvider bean

作为自己实现此功能的另一种替代方法,您可以使用。这个Redis客户端带有一个公开普罗米修斯度量的。您的指标将与您的提示一样:

# HELP cache_gets_total the number of times cache lookup methods have returned an uncached (newly loaded) value, or null
# TYPE cache_gets_total counter
cache_gets_total{cache="...",cacheManager="...",name="...",result="miss",} 0.0
cache_gets_total{cache="...",cacheManager="...",name="...",result="hit",} 0.0

# HELP cache_puts_total The number of entries added to the cache
# TYPE cache_puts_total counter
cache_puts_total{cache="...",cacheManager="...",name="...",} 0.0