在Kubernetes上带有多容器吊舱的Prometheus

car*_*ray 3 monitoring docker kubernetes prometheus

我的kubernetes部署中有一个多容器容器:

  • 爪哇
  • Redis
  • Nginx的

对于每个容器,都有一个带有Prometheus出口商的容器。

问题是,如果注释部分每个吊舱仅支持一个端口,如何将这些端口暴露给Prometheus?

annotations:
  prometheus.io/scrape: 'true'
  prometheus.io/port: 'xxxx'
Run Code Online (Sandbox Code Playgroud)

但我需要这样的东西:

annotations:
  prometheus.io/scrape: 'true'
  prometheus.io/port_1: 'xxxx'
  prometheus.io/port_2: 'yyyy'
  prometheus.io/port_3: 'zzzz'
Run Code Online (Sandbox Code Playgroud)

也许还有其他方法可以从多容器容器中抓取所有指标?在此先感谢您提供的任何帮助。

car*_*ray 5

这是Prometheus 的示例工作。将其放在您自己的配置中。

接下来,添加:

annotations:
   prometheus.io/scrape: 'true'
Run Code Online (Sandbox Code Playgroud)

到您的pod元数据。

然后在每个提供/ metrics的容器上创建一个名为的适当端口metrics

而已。Prometheus仅会抓取这些端口,并且不会出现任何情况,例如您的redis实例将在其6379端口上获得http请求时。

  • 一个示例 yaml 会非常有帮助。 (4认同)