第 4 章 HTTP 指标
Micrometer 扩展自动为 HTTP 服务器请求。遵循 timers 的 Prometheus 命名约定,查找 http_server_requests_seconds_count、http_server_requests_seconds_sum 和 http_server_requests_seconds_max。为请求的 uri、HTTP 方法(GET、POST 等)、状态代码(200、302、404 等)和更常规的结果字段添加了标头标签。
忽略端点
您可以使用 quarkus.micrometer.binder.http-server.ignore-patterns 属性来禁用 HTTP 端点的测量。此属性接受以逗号分隔的简单正则表达式列表,用于识别应忽略的 URI 路径。例如,设置 quarkus.micrometer.binder.http-server.ignore-patterns=/example/prime/[0-9]+ 将忽略对 http://localhost:8080/example/prime/7919 的请求。仍然会测量对 http://localhost:8080/example/gauge/7919 的请求。
URI 模板
Micrometer 扩展将在代表以模板形式表示路径参数的 URI 时做出最佳努力。使用以上 http://localhost:8080/example/prime/7919 的示例,到 http://localhost:8080/example/prime/7919 的请求应该显示为 http_server_requests_seconds_* 指标的属性,其标签为 uri=/example/prime/{number}。
如果无法确定正确的 URL,请使用 quarkus.micrometer.binder.http-server.match-patterns 属性。此属性接受以逗号分隔列表,定义简单正则表达式匹配模式和替换字符串之间的关联。例如,设置 quarkus.micrometer.binder.http-server.match-patterns=/example/prime/[0-9]+=/example/{jellybeans} 的值将值 /example/{jellybeans} 用于 uri 与 /example/prime/[0-9]+ 匹配时。