Prometheus 如何通过身份验证抓取 Spring Boot 指标?

Iva*_*cki 6 spring-security spring-boot spring-boot-actuator prometheus

我正在使用 Spring Boot 1.5.1:

compile 'io.micrometer:micrometer-spring-legacy:1.0.6'
compile 'io.micrometer:micrometer-registry-prometheus:1.0.6'
Run Code Online (Sandbox Code Playgroud)

弹簧属性文件:

management.security.enabled=true
endpoints.prometheus.enabled=true
endpoints.prometheus.sensitive=false
Run Code Online (Sandbox Code Playgroud)

在我的 Prometheus 配置文件中,我添加了 basic_auth:

basic_auth:
    username: username
    password: passw0rd
Run Code Online (Sandbox Code Playgroud)

在我的 [prometheusURL]/targets 中,我不断收到:

服务器返回 HTTP 状态 403

Prometheus 验证每个 Spring 指标的正确方法是什么?

编辑:我可以使用以下命令通过 Spring Security:

curl --cookie "SESSION=7f18cfe7-9a54-4fcf-9662-21d81247c705" http://localhost:8082/management/metrics
Run Code Online (Sandbox Code Playgroud)

AFAIK 在prometheus 配置文件中我们只能传递basic_authbearer_token。标题没有其他选项。