Abhay Gupta
Abhay Gupta

Reputation: 11

Metrics are not supported for Spring Boot 1.x applications

I am using Spring Boot 2.x but in Spring Boot Admin-> Wallboard -> Metrics I am getting "Metrics are not supported for Spring Boot 1.x applications".

Upvotes: 0

Views: 435

Answers (1)

TobiasMende
TobiasMende

Reputation: 761

I had the same issue and the reason was, that my application always sent a fixed content-type in the response header.

Spring Boot Admin checks for the content-type application/vnd.spring-boot.actuator.v2. If this content-type is absent, your application is considered to be a Spring Boot 1 application.

In my case, the reason was a WebMvcConfigurer which hard-coded the defaultContentType to application/json. I had something like the following in my configurer:

@Override
    public void configureContentNegotiation(ContentNegotiationConfigurer configurer) {
      configurer.defaultContentType(MediaType.APPLICATION_JSON)
                .favorPathExtension(false).favorParameter(true).ignoreAcceptHeader(true).useRegisteredExtensionsOnly(true);
    }

After changing it to

@Override
    public void configureContentNegotiation(ContentNegotiationConfigurer configurer) {
        configurer.defaultContentType(MediaType.valueOf("application/vnd.spring-boot.actuator.v2+json"), MediaType.APPLICATION_JSON)
                .favorPathExtension(false).favorParameter(true).ignoreAcceptHeader(true).useRegisteredExtensionsOnly(true);
    }

, Spring Boot Admin showed me the metrics as it was supposed to.

Upvotes: 2

Related Questions