Metrics http_server_requests_seconds_count in spring boot application using cxf-spring-boot-starter-jaxrs contains uri as "UNKNOWN"

http_server_requests_seconds_sum
micrometer-jersey2

Metrics http_server_requests_seconds_count in Spring Boot application with version 2.0.8.Release exposed using spring actuator contains URI as:

"UNKNOWN".

Spring Boot application is using cxf-spring-boot-starter-jaxrs for exposing rest endpoints. I have added micrometer-registry-prometheus dependency in my project.

http_server_requests_seconds_count{exception="None",method="POST",status="200",uri="UNKNOWN",} 2.0

I have tried adding micrometer-jersey2 dependency in my project.

Actual

http_server_requests_seconds_count{exception="None",method="POST",status="200",uri="UNKNOWN",} 2.0

Expected:

http_server_requests_seconds_count{exception="None",method="GET",status="200",uri="/sayHello",} 2.0

After the clarification in OP comments (CXF being another JAX-RS implementation): There's currently no support in Micrometer to handle CXF requests. It (Spring WebMvc) can't extract the optionally parameterized request url and in that case falls back to UNKNOWN. (Otherwise this could lead to a metrics explosion if your CXF endpoints provide some highly parameterizable URLs which get a lot of traffic.)

So you could have a look at the micrometer-jersey2 implementation and derive a micrometer-cxf implementation ;) (Or if not already the case (use the search) - open up an issue with the Micrometer or CXF project. I am mentioning the latter, because they might be interessted in taking care of that implementation.)

Metrics http_server_requests_seconds_count in spring - html, Metrics http_server_requests_seconds_count in spring boot application using cxf -spring-boot-starter-jaxrs contains uri as “UNKNOWN” - spring. http_server_requests_seconds_count is a metric to hold the count of HTTP requests (don’t worry about the fact that the name contains the word seconds). To learn about other default metrics check out the Spring Boot default metrics article.

You can also collect cxf metrics for prometheus using io.github.ddk-prog:cxf-prometheus-metrics.

Add dependency to your pom.xml

<dependency>
    <groupId>io.github.ddk-prog</groupId>
    <artifactId>cxf-prometheus-metrics</artifactId>
    <version>1.0.0</version>
</dependency>

and the following bean to your application configuration.

@Bean
public FactoryBeanListener cxfPrometheusFeatureBean(final CollectorRegistry registry) {
    return new PrometheusFactoryBeanListener(registry);
}

You will get cxf_requests_total, cxf_requests_success, cxf_requests_failed, cxf_requests_seconds for each endpoint and operation in your spring boot actuator prometheus report. For example,

cxf_requests_seconds{endpoint="server1",operation="server1Method",} 0.0157349

Instrument Apache CXF's JAX-RS implementation � Issue #1364 , Metrics http_server_requests_seconds_count in Spring Boot application Release exposed using spring actuator contains uri as "UNKNOWN". Spring Boot application is using cxf-spring-boot-starter-jaxrs for exposing rest en. For instance, consider the metric http_server_requests_seconds_count. If there are more than one API endpoints (which is the case in an eco-system of microservices), then without dimensions, one can only view the aggregated values of this metric at the platform level. It won’t be possible to get a distribution across different API endpoints.

If you need cxf statistics for micrometer report, you can try

<dependency>
    <groupId>io.github.kdprog</groupId>
    <artifactId>cxf-micrometer-metrics</artifactId>
    <version>1.0.0</version>
</dependency>

The following statistics will be reported

cxf_requests_processed_total - total number of cxf requests ,
cxf_requests_seconds_sum     - total execution time of cxf requests,
cxf_requests_seconds_max     - maximum execution time of cxf request,
cxf_requests_success_total   - total number of successfully processed cxf requests,
cxf_requests_failed_total    - total number of failed cxf requests

for each web service method of every client or server cxf endpoint.

For spring applications add the following bean to your application configuration.

@Bean
public FactoryBeanListener cxfMicrometerBean(final MeterRegistry registry) {
    return new MicrometerFactoryBeanListener(registry);
}

Metrics http_server_requests_seconds_count in spring , Release exposed using spring actuator contains URI as: "UNKNOWN". Spring Boot application is using cxf-spring-boot-starter-jaxrs for� Spring Boot Actuator and Micrometer overview. The Spring Boot Actuator exposes many different monitoring and management endpoints over HTTP and JMX. It includes the all-important metrics capability, by integrating with the Micrometer application monitoring framework.

Instrument Apache CXF's JAX-RS implementation, Metrics http_server_requests_seconds_count in Spring Boot application with version 2.0.8.Release exposed using spring actuator contains uri as "UNKNOWN ". Spring Boot application is using cxf-spring-boot-starter-jaxrs for exposing rest� Dropwizard metrics is such a tool, which makes it very easy to create metrics within our Java application. Injecting the MetricsRegistry. First off, you will need a MetricRegistry object at which to register the metrics you want to measure. In a Spring Boot application, you simply have to add a dependency to the Dropwizard metrics library.

How to enable Spring MVC metrics in Spring Boot 2x Actuator , As it turned out - you need to do at least one http request to the application itself - excluding the management endpoints. Just hitting any url within the app with a� Enabling metrics in your Spring Boot application configures a BeanPostProcessor for RestTemplate, so every instance you create via the application context will be instrumented. A timer is recorded for each invocation that includes tags for URI (before parameter substitution), host, and status.

Apache CXF -- SpringBoot, Apache CXF, Services Framework - SpringBoot. artifactId >cxf-spring-boot- starter-jaxws</ artifactId > alongside this Configuration is sufficient for enabling a CXF JAX-WS endpoint which will respond to SOAP request URI such as Note the use of CXF JAX-RS Clients in SpringBoot Application is covered in this section. Please also see a JAX-WS Spring Boot demo. Spring Boot CXF JAX-RS Starter Features. Registers CXF Servlet with a "/services/*" URL pattern for serving CXF JAX-RS endpoints. Optionally auto-discovers JAX-RS root resources and providers and creates a JAX-RS endpoint. Note the use of CXF JAX-RS Clients in SpringBoot Application is covered in this

Comments
  • Wasn't Apache CXF another/alternate JAX-RS implementation?micrometer-jersey2 explicitely only supports the Jersey JAX-RS implementation.
  • Yes Apache CXF is an alternate implementation for JAX-RS. Micrometer provides only jersey module, there is no such module for CXF.