简体   繁体   English

普罗米修斯与kubernetes上的多容器豆荚

[英]Prometheus with multi-container pod on kubernetes

I have a multi-container pod in my kubernetes deployment: 我的kubernetes部署中有一个多容器窗格:

  • java java的
  • redis Redis的
  • nginx nginx的

For every of those containers, there's a container with Prometheus exporter as well. 对于每个容器,都有一个带有Prometheus出口商的容器。

The question is how can I expose those ports to Prometheus if annotations section supports only one port per pod? 问题是如果注释部分每个pod只支持一个端口,我该如何将这些端口暴露给Prometheus?

annotations:
  prometheus.io/scrape: 'true'
  prometheus.io/port: 'xxxx'

but I need something like this: 但我需要这样的东西:

annotations:
  prometheus.io/scrape: 'true'
  prometheus.io/port_1: 'xxxx'
  prometheus.io/port_2: 'yyyy'
  prometheus.io/port_3: 'zzzz'

Maybe there's some other method to scrape all metrics from my multi-container pods? 也许有一些其他方法可以从我的多容器pod中删除所有指标? Thanks in advance for any kind of help. 提前感谢您提供任何帮助。

Here's an example job for Prometheus. 这是普罗米修斯的榜样 Put it in your own config. 把它放在你自己的配置中。

Next, add: 接下来,添加:

annotations:
   prometheus.io/scrape: 'true'

to your pod metadata. 到你的pod元数据。

And on every container, which provides /metrics to prom, create an appropriate port, named metrics . 在为prom提供/ metrics的每个容器上,创建一个名为metrics的适当端口。

That's it. 而已。 Prometheus would scrape only those ports, and there would be no situation, like when your redis instance would get http requests on its 6379 port. Prometheus只会刮掉那些端口,并且没有任何情况,例如当你的redis实例在其6379端口上获得http请求时。

The annotations you propose should work. 你提出的注释应该有用。 Create one scrape_config per port annotation, keeping only targets matching the corresponding annotation port name. 为每个端口注释创建一个scrape_config,仅保留与相应注释端口名称匹配的目标。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM