【问题标题】:How prometheus consul service discovery works if ACL is enabled?如果启用 ACL,prometheus consul 服务发现如何工作?
【发布时间】:2021-04-16 10:37:33
【问题描述】:

我在 Consul 注册了一些服务,我必须使用 Prometheus 监控在 Consul 注册的服务。

Prometheus 提供了consul_sd_config 用于服务发现,但我在 consul 中启用了 ACL 以确保安全,并且使用 consul 目录 API 需要令牌,Prometheus 是如何解决这些问题的?

【问题讨论】:

    标签: prometheus acl consul


    【解决方案1】:

    我不确定有什么不清楚的地方。这一切都在您提供的链接中进行了描述:)

    1. 您创建的 ACL 允许读取已注册的服务
    2. 获取 ACL 令牌并将其与其他信息一起用于 Prometheus 配置 - https://prometheus.io/docs/prometheus/latest/configuration/configuration/#consul_sd_config 中描述的所有内容
    # The information to access the Consul API. It is to be defined
    # as the Consul documentation requires.
    [ server: <host> | default = "localhost:8500" ]
    [ token: <secret> ]
    [ datacenter: <string> ]
    [ scheme: <string> | default = "http" ]
    [ username: <string> ]
    [ password: <secret> ]
    

    【讨论】:

    • 感谢回复,我的token是ACL在运行时生成的,如何在YML文件中填写?
    • 我是指“运行时”。 ACL 是通过 GUI 或 API 显式创建的。在 GUI 中,您可以转到 ACL 选项卡以查看 ACL 列表。您找到您的 ACL,单击其名称,您可以在其中看到您的令牌。你读过这个指南吗?:learn.hashicorp.com/tutorials/consul/…
    • 抱歉没有描述性。我正在处理一个具有微服务架构的应用程序,consul 和 Prometheus 是微服务,它们使用 docker 进行容器化。我在 consul 中公开了用于读取访问令牌的 API。我认为我必须在 prometheus.yml 中使用该令牌,但是该令牌是由 consul 动态生成的,我该如何在这里使用它? P.S 我使用的技术栈是 Node.js
    猜你喜欢
    • 2014-09-20
    • 1970-01-01
    • 2015-11-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-08-16
    • 2017-05-08
    相关资源
    最近更新 更多