<p>I have a multi-container pod in my kubernetes deployment:</p>

<ul>
<li>java</li>
<li>redis</li>
<li>nginx</li>
</ul>

<p>For every of those containers, there's a container with Prometheus exporter as well. </p>

<p>The question is how can I expose those ports to Prometheus if annotations section supports only one port per pod?</p>

<pre><code>annotations:
  prometheus.io/scrape: 'true'
  prometheus.io/port: 'xxxx'
</code></pre>

<p>but I need something like this:</p>

<pre><code>annotations:
  prometheus.io/scrape: 'true'
  prometheus.io/port_1: 'xxxx'
  prometheus.io/port_2: 'yyyy'
  prometheus.io/port_3: 'zzzz'
</code></pre>

<p>Maybe there's some other method to scrape all metrics from my multi-container pods? Thanks in advance for any kind of help.</p>

<p>Here's an <a href="https://gist.github.com/bakins/5bf7d4e719f36c1c555d81134d8887eb" rel="noreferrer">example</a> job for Prometheus. Put it in your own config.</p>

<p>Next, add:</p>

<pre><code>annotations:
   prometheus.io/scrape: 'true'
</code></pre>

<p>to your pod metadata.</p>

<p>And on every container, which provides /metrics to prom, create an appropriate port, named <code>metrics</code>.</p>

<p>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.</p>
