1

我想使用 Prometheus 的 Consul 集成来自动发现我所有的 consul 节点。目前,我的 Prometheus 服务器仅从Consul 中的单个数据中心接收节点,尽管我从未真正指定在配置中使用哪个数据中心(我猜它只是选择了我的 consul-client(安装在我的 prometheus 服务器上)是其中的一部分的)。

我如何从consul 知道的所有数据中心获取所有节点?

4

1 回答 1

6

我们找到的解决方案是在配置中使用“数据中心”关键字 - 并明确列出我们拥有的数据中心。它不是最优的(因为我们将来可能会添加/删除数据中心)但它确实有效。下面是一个例子:

scrape_configs:
  - job_name: 'consul'
    consul_sd_configs:
       - server:   '0.0.0.0:8500'
         datacenter: 'datacenter-name-1'
       - server:   '0.0.0.0:8500'
         datacenter: 'datacenter-name-2'
       - server:   '0.0.0.0:8500'
         datacenter: 'datacenter-name-3'
于 2016-11-01T06:58:50.830 回答