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

SpringBoot Actuator获取带PathVariable的http.server.requests指标失败求助

解决Spring Actuator带PathVariable接口指标查询问题
  • 先确认可用的uri标签值
    发起请求:GET http://localhost.com:8449/actuator/metrics/http.server.requests,返回结果里会列出该指标下所有的uri标签选项。对于带@PathVariable的接口,这里的uri值可能是/myParamAPI/{myParam},也可能因版本或配置显示为/myParamAPI/*。

  • 使用正确的查询格式
    如果查到的uri标签是/myParamAPI/{myParam},注意大括号是URL特殊字符,必须编码后再查询。正确的请求地址应为:
    http://localhost.com:8449/actuator/metrics/http.server.requests?tag=uri:/myParamAPI/%7BmyParam%7D
    (%7B对应{的URL编码,%7D对应}的URL编码)

  • 自定义指标聚合规则(可选)
    如果默认的uri聚合不符合需求,可以在配置文件中调整:

    # 按路径模板聚合uri指标(默认开启,保留占位符形式)
    management.metrics.web.server.request-mapping-including-path-variables=true
    # 若要让指标保留实际请求的参数值(不推荐,会导致指标基数过大)
    # management.metrics.web.server.request-mapping-including-path-variables=false
    

    配置完成后重启应用即可生效。

内容的提问来源于stack exchange,提问作者Nanda

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.28 12:05:09