Spring Boot zalando logbook 过滤不打印指定请求
Spring Boot About 506 words需求
zalando logbook会打印很多prometheus收集监控数据的HTTP请求数据。
如:/actuator/prometheus、/actuator/health等接口。
解决方法
过滤指定的HTTP请求。
代码
注入Predicate<HttpRequest>,返回false表示过滤掉该请求,不进行logbook的脱敏处理。
@Bean
public Predicate<HttpRequest> requestCondition() {
    return (httpRequest) -> {
        log.info("requestCondition#{}, {}", httpRequest.getRequestUri(), httpRequest.getPath());
        if (httpRequest.getPath().equals("/actuator/prometheus")) {
            return false;
        }
        return true;
    };
}
                Views: 1,321 · Posted: 2023-07-14
            
            ————        END        ————
Give me a Star, Thanks:)
https://github.com/fendoudebb/LiteNote扫描下方二维码关注公众号和小程序↓↓↓
        Loading...