Spring Boot 2执行器指标缓存

时间:2018-08-22 17:56:11

标签: spring-boot spring-boot-actuator

我有一些缓存

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

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

我得到“ /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的命中和未命中值?

1 个答案:

答案 0 :(得分:0)

您应按照此处的说明使用标签: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