After upgrading to Spring Boot 2.3.0, I found that the Prometheus actuator endpoint returns an HTTP 500 response, if an Accept: application/json
header is passed in the request. Actually, it seems that it happens with any JSON MIME type, e.g. application/vnd.something+json
, but not with other MIME types, such as application/xml
.
With Spring Boot 2.2.5, the response was HTTP 406, which is what I'd expect.
Comment From: wilkinsona
Thanks for the report, @mario-philipps-icw. Unfortunately, I cannot reproduce the behaviour you have described. I receive a 406 response from an app:
$ curl -H Accept:application/json http://localhost:8080/actuator/prometheus -i
HTTP/1.1 406
Content-Type: application/json
Transfer-Encoding: chunked
Date: Thu, 28 May 2020 08:18:20 GMT
{"timestamp":"2020-05-28T08:18:20.186+00:00","status":406,"error":"Not Acceptable","message":"","path":"/actuator/prometheus"}
This was using spring-boot-starter-web
. I also received a 406 in an integration test:
@WebEndpointTest
void whenAcceptedContentTypeCannotBeProducedScrapeFailsWithNotAcceptable(WebTestClient client) {
client.get().uri("/actuator/prometheus").accept(MediaType.APPLICATION_JSON).exchange().expectStatus()
.isEqualTo(HttpStatus.NOT_ACCEPTABLE);
}
This was added to PrometheusScrapeEndpointIntegrationTests
and covers WebFlux, WebMVC, and Jersey based endpoints.
If you would like us to spend some more time investigating, please spend some time creating a minimal sample that reproduces the problem. You can share it with us by pushing it to a separate repository on GitHub or zipping it up and attaching it to this issue.
Comment From: mario-philipps-icw
Further research revealed that the problem occurs when a separate management port is configured via management.server.port
. When the default is used (no separate port), everything works fine.
Minimal (Kotlin) example application is attached, including a failing unit test.
Comment From: wilkinsona
Thanks very much, @mario-philipps-icw. The use of a separate management port was the missing piece. I can reproduce the problem now.
Comment From: scottfrederick
I've confirmed that this is another side-effect of the initial fix for #21036, with the same problem noted there: https://github.com/spring-projects/spring-boot/issues/21036#issuecomment-637743042. Marking this issue as a duplicate of the forward-merge issue #21875 for 2.3.1
.