首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >配置Prometheus Pushgateway的千分尺-添加基本的Auth凭证

配置Prometheus Pushgateway的千分尺-添加基本的Auth凭证
EN

Stack Overflow用户
提问于 2022-08-26 16:24:07
回答 1查看 151关注 0票数 0

我有一个使用千分尺的Pushgateway的Spring应用程序,主要基于本教程:https://luramarchanjo.tech/2020/01/05/spring-boot-2.2-and-prometheus-pushgateway-with-micrometer.html

pom.xml有以下相关的依赖关系:

代码语言:javascript
复制
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
    <groupId>io.micrometer</groupId>
    <artifactId>micrometer-core</artifactId>
</dependency>
<dependency>
    <groupId>io.micrometer</groupId>
    <artifactId>micrometer-registry-prometheus</artifactId>
</dependency>
<dependency>
    <groupId>io.prometheus</groupId>
    <artifactId>simpleclient_pushgateway</artifactId>
    <version>0.16.0</version>
</dependency>

application.properties文件有:

代码语言:javascript
复制
management.metrics.export.prometheus.pushgateway.enabled=false
management.metrics.export.prometheus.pushgateway.shutdown-operation=PUSH
management.metrics.export.prometheus.pushgateway.baseUrl=localhost:9091

在Dev环境中,它在没有任何身份验证的情况下连接到Pushgateway时,在本地运行良好。在我们的CI环境中,Prometheus Pushgateway已经启用了基本功能。如何在这个Spring引导应用程序中配置基本的auth凭据?

EN

回答 1

Stack Overflow用户

发布于 2022-08-29 21:10:13

看来弹簧启动的自动配置和Prometheus的PushGateway都不支持直接提供凭据。

我想你可以做两件事:

  1. 我不确定HTTP是否支持它,但有些确实/确实支持在url中传递凭证,这些凭据将被转换为headers:https://serverfault.com/a/371918
  2. 您还可以创建自己的PrometheusPushGatewayManager bean,并在将PushGateway传递给PrometheusPushGatewayManager的ctor之前,使用具有creds的工厂在PushGateway实例上调用PushGateway
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73503973

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档