We recently updated from Springboot 3.4.9/Micrometer 1.12.5 (which apparently was too old for that Springboot version, but worked) to Springboot 3.5.6 and Micrometer 1.15.4 We are running a dedicated management server, have remapped actuator to "/" and mapped the Prometheus endpoint to /metrics, by setting these properties:
management.server.port=8081
management.endpoints.web.base-path=/
management.endpoint.prometheus.access=read_only
management.prometheus.metrics.export.enabled=true
management.endpoints.web.path-mapping.prometheus=metrics
This is the config that had been working before the version update (albeit we used the now deprecated
management.endpoint.prometheus.enabled=true
instead of
management.endpoint.prometheus.access=read_only
but switching back to that makes no difference).
When accessing the Prometheus endpoint (whether we let Prometheus scape itself or just curl the endpoint), we get a status 500, the response when using plain
curl <host>:<port>/metrics
is
{"timestamp":1758895051901,"status":500,"error":"Internal Server Error","path":"/metrics"}
At that moment, the Springboot app logs this line
DefaultHandlerExceptionResolver - Resolved [org.springframework.http.converter.HttpMessageNotWritableException: No converter for [class [B] with preset Content-Type 'text/plain;version=0.0.4;charset=utf-8']
I debugged into this a bit.
Apparently PrometheusScrapeEndpoint
provides the result as a bytearray (which I found somewhat surprising).
When trying to convert this to an actual HTTP response org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodProcessor
has two available message converters:
- StringHttpMessageConverter
- this can produce text/plain responses, but only handles String result objects.
- MappingJackson2HttpMessageConverter
- this can support any class of result objects, but produces only application/json content types.
I am not sure what the actual constellation should be here - a converter that supports bytearrays and can produce text/plain responses? Or should the PrometheusScrapeEndpoint (or rather some equivalent) actually produce a String result (I find the latter more naturally, obviously).
Any hints appreciated.
Regards
PPF
Comment From: wilkinsona
I cannot reproduce the described behavior. If you would like us to spend some more time investigating, please spend some time providing a complete yet minimal sample that reproduces the problem. You can share it with us by pushing it to a separate repository on GitHub or by zipping it up and attaching it to this issue.