执行器指标标记PathVariable和通配符

问题描述 投票:1回答:1

我正在使用Spring Boot 2执行器指标来统计API请求。但是我遇到了一些问题,并且找不到太多相关文件。

请求总数导致4xx响应

请求总数导致5xx响应

1,

我可以使用http://localhost:8080/travel/actuator/metrics/http.server.requests?tag=status:400获取状态400信息,但我想知道是否有任何方法可以对4xx请求进行通配?还是我必须在代码中一遍一遍地循环所有4xx状态代码?

2,

  @GetMapping("/{type}/{code}")
  public Mono<ResponseEntity<Location>> getLocationByTypeAndCode(
  @NotNull @PathVariable("type") final String type,
  @NotNull @PathVariable("code") final String code) {

我在控制器中使用PathVariable参数,但是当我使用http://localhost:8080/travel/actuator/metrics/http.server.requests?tag=uri:/locations/{type} / {code}

我收到400错误的请求错误

我是Spring Boot Actuator的新手,非常感谢您的帮助!

spring-boot spring-boot-actuator
1个回答
0
投票

1:要获取所有4xx错误,可以使用:?tag=outcome:CLIENT_ERROR

2:方括号需要进行URL编码:?tag=uri:/locations/%7Btype%7D/%7Bcode%7D

© www.soinside.com 2019 - 2024. All rights reserved.