Spring Boot 2 执行器指标缓存

问题描述:

我有一些缓存

@Service
@CacheConfig(cacheNames = "myCache")
public class MyService { ... }

@Service
@CacheConfig(cacheNames = "myOtherCache")
public class MyOtherService { ... }

我得到/actuator/metrics/cache.gets"

I get with "/actuator/metrics/cache.gets"

{
  "name" : "cache.gets",
  "measurements" : [ {
    "statistic" : "COUNT",
    "value" : 5.0
  } ],
  "availableTags" : [ {
    "tag" : "result",
    "values" : [ "hit", "miss" ]
  }, {
    "tag" : "cache",
    "values" : [ "myCache", "myOtherCache" ]
  }, {
    "tag" : "name",
    "values" : [ "myCache", "myOtherCache" ]
  }, {
    "tag" : "cacheManager",
    "values" : [ "cacheManager" ]
  } ]
}

如何获取 myCache 和 myOtherCache 的命中和未命中值?

how can I obtain the hit and miss values for myCache and myOtherCache?

你应该使用这里解释的标签:http://blog.davidvassallo.me/2018/03/13/drill-down-into-spring-boot-actuator-metrics/

You should use the tags as explained here : http://blog.davidvassallo.me/2018/03/13/drill-down-into-spring-boot-actuator-metrics/

GET .../actuator/metrics/cache.gets?tag=name:myCache
GET .../actuator/metrics/cache.gets?tag=name:myOtherCache