I am using Spring Boot 2.0.3.RELEASE with following dependencies:
spring-boot-starter-actuator:2.0.3.RELEASE
micrometer-core:1.0.6
micrometer-registry-prometheus:1.0.6
But when I invoke Prometheus all I keep getting is
{
"timestamp": 1532426317772,
"status": 406,
"error": "Not Acceptable",
"message": "Could not find acceptable representation",
"path": "/actuator/prometheus"
}
*and/or from browser*
There was an unexpected error (type=Not Acceptable, status=406).
Could not find acceptable representation
I have also tried previous Prometheus releases of the range 1.0.X with Spring Boot 2 but with no luck. Could someone please suggest some insights? Many thanks.
We recently had the same problem. While debugging Spring Boot I discovered that we had no HttpMessageConverter registered that could handle the "text/plain" MediaType, only "application/json". Because the Prometheus endpoint returns the "text/plain" MediaType we added some configuration as a temporary workaround. We added a StringHttpMessageConverter linked to the specific MediaType.
@Configuration
public class ApplicationConfiguration implements WebMvcConfigurer {
@Override
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
StringHttpMessageConverter converter = new StringHttpMessageConverter();
converter.setSupportedMediaTypes(Arrays.asList(MediaType.TEXT_PLAIN));
converters.add(converter);
}
}
Hope this helps you
May It's 406 status code which also can solved by client side with specified accept header.
like this: curl -v -H "Accept: text/plain" url
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With