Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In v2.3.0, Prometheus endpoint returns HTTP 500 in response to "Accept: application/json" #21591

Closed
mario-philipps-icw opened this issue May 27, 2020 · 4 comments
Assignees
Labels
status: duplicate A duplicate of another issue

Comments

@mario-philipps-icw
Copy link

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.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label May 27, 2020
@wilkinsona wilkinsona self-assigned this May 28, 2020
@wilkinsona
Copy link
Member

wilkinsona commented May 28, 2020

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.

@wilkinsona wilkinsona added the status: waiting-for-feedback We need additional information before we can continue label May 28, 2020
@wilkinsona wilkinsona removed their assignment May 28, 2020
@mario-philipps-icw
Copy link
Author

mario-philipps-icw commented Jun 2, 2020

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.

myapplication.tar.gz

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Jun 2, 2020
@wilkinsona
Copy link
Member

wilkinsona commented Jun 2, 2020

Thanks very much, @mario-philipps-icw. The use of a separate management port was the missing piece. I can reproduce the problem now.

@wilkinsona wilkinsona added type: regression A regression from a previous release and removed status: feedback-provided Feedback has been provided status: waiting-for-triage An issue we've not yet triaged labels Jun 2, 2020
@wilkinsona wilkinsona added this to the 2.3.1 milestone Jun 2, 2020
@scottfrederick
Copy link
Contributor

scottfrederick commented Jun 10, 2020

I've confirmed that this is another side-effect of the initial fix for #21036, with the same problem noted there: #21036 (comment). Marking this issue as a duplicate of the forward-merge issue #21875 for 2.3.1.

@scottfrederick scottfrederick added status: duplicate A duplicate of another issue and removed type: regression A regression from a previous release labels Jun 10, 2020
@scottfrederick scottfrederick removed this from the 2.3.1 milestone Jun 10, 2020
@scottfrederick scottfrederick self-assigned this Jun 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: duplicate A duplicate of another issue
Projects
None yet
Development

No branches or pull requests

4 participants