I am with a Spring Boot project with WebFlux + Spring Reactor, and it calls other services with ReactiveFeignClient
.
How can I integrate Prometheus so that I could monitor response time (with a @Timer
) and the percentage of each status code returned by feign call? Like 200, 400, 404... I have only found ways to:
- monitor endpoint response time/status code(
http_server_requests_seconds
) - monitor
RestTemplate
(as explained here: https://docs.spring.io/spring-metrics/docs/current/public/prometheus, but I use feign)
After all the work I have done, I have seen no reactive feign clients meters in Prometheus output, even though I defined the bean of logger like:
@Bean
public MetricsWebClientFilterFunction metricsWebClientFilterFunction(PrometheusMeterRegistry meterRegistry,
WebClientExchangeTagsProvider provider) {
return new MetricsWebClientFilterFunction(
meterRegistry,
provider,
APP_NAME + "reactive-client-request",
AutoTimer.ENABLED
);
}
@Bean
public MicrometerReactiveLogger feignReactiveLogger(Clock clock,
PrometheusMeterRegistry meterRegistry) {
return new MicrometerReactiveLogger(
clock,
meterRegistry,
APP_NAME + ".feign.client_metrics",
MetricsTag.getMandatory()
);
}
Also, I found it impossible to enable /actuator/prometheus
, but only /_system/check/prometheus
. I did enable and expose the endpoints of metrics
and prometheus
.
management:
health:
diskspace:
enabled: false
endpoint:
metrics.enabled: true
prometheus.enabled: true
endpoints:
web:
base-path: /_system/check
exposure:
include: info,health,loggers,metrics,prometheus
path-mapping:
health: /simple
I found the problem: the metrics related with reactive feign clients will only show after you actually do feign calls. Before that they are hidden.
Reactive Feign Client uses
WebClient
underneath and will be measured automatically with presence of Spring Actuator.