You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何让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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.03 20:40:54