如何让Spring Boot Actuator返回text/plain以在浏览器查看Prometheus指标?
解决Spring Boot Actuator Prometheus端点浏览器下载而非展示的问题
不用编写服务端拦截器,直接通过Spring Boot配置就能修改Prometheus端点的响应内容类型为text/plain,具体配置如下:
方式一:application.properties配置
management.endpoints.web.media-types.productions.prometheus=text/plain
方式二:application.yml配置
management: endpoints: web: media-types: productions: prometheus: text/plain
配置完成后重启应用,再次访问/actuator/prometheus,浏览器会直接渲染返回的指标内容,而不是触发下载。这个配置直接指定了Prometheus端点的响应媒体类型,无需编写任何自定义代码。
内容的提问来源于stack exchange,提问作者Giles Thompson
相关产品推荐
相关产品推荐

