【问题标题】:How to dynamically manage prometheus file_sd_configs in docker container?如何在docker容器中动态管理prometheus file_sd_configs?
【发布时间】:2019-10-28 20:39:49
【问题描述】:

我一直在本地运行的 node.js 应用程序中使用targets.json 来动态添加 ip 地址,以便 prometheus 以 file_sd_configs 选项探测服务发现。它运作良好。我能够添加新的 ip 并从节点应用程序执行 prometheus reload api,监控这些 ip 并发出警报(使用 blackbox 和 alertmanager)。

但是,现在应用程序和 prometheus 在同一网络上的 docker 内运行。如何让我的节点应用程序写入 prometheus 容器中文件夹内的文件(或更新它)?

【问题讨论】:

  • Prometheus 的强项之一是能够使用云原生服务发现。根据您的编排风格,您通常可以使用 API 来发现服务。

标签: node.js docker docker-compose prometheus service-discovery


【解决方案1】:

您可以通过将卷映射添加到您的 docker-compose 文件,将 target.json 文件绑定到 Prometheus 和应用程序容器。

 volumes:
  - /hostpath/target.json:/containerpath/target.json

除了使用映射的主机系统文件夹之外,您还可以使用命名卷,有关 docker 卷的更多信息,请参阅here

【讨论】:

  • 感谢分享这种方法。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2021-03-11
  • 1970-01-01
  • 2017-10-17
  • 2015-12-21
  • 2017-07-05
  • 2019-02-09
  • 1970-01-01
相关资源
最近更新 更多