<p><strong>Background</strong></p>

<p>I have installed Prometheus on my Kubernetes cluster (hosted on Google Container Engineer) using the <a href="https://github.com/kubernetes/charts/tree/master/stable/prometheus" rel="noreferrer">Helm chart for Prometheus</a>.</p>

<p><strong>The Problem</strong></p>

<p>I cannot figure out how to add scrape targets to the Prometheus server. The prometheus.io site describes how I can mount a prometheus.yml file (which contains a list of scrape targets) to a Prometheus Docker container -- I have done this locally and it works. However, I don't know how to specify scrape targets for a Prometheus setup installed via Kubernetes-Helm. Do I need to add a volume to the Prometheus server pod that contains the scrape targets, and therefore update the YAML files generated by Helm??</p>

<p>I am also not clear on how to expose metrics in a Kubernetes Pod -- do I need to forward a particular port?</p>

<p>You need to add annotations to the service you want to monitor.</p>

<pre><code>apiVersion: v1
kind: Service
metadata:
  annotations:
    prometheus.io/scrape: 'true'
</code></pre>

<p>From the prometheus.yml in the chart:</p>

<ul>
<li><code>prometheus.io/scrape</code>: Only scrape services that have a value of <code>true</code> </li>
<li><code>prometheus.io/scheme</code>: http or https</li>
<li><code>prometheus.io/path</code>: override if the metrics path is not <code>/metrics</code></li>
<li><code>prometheus.io/port</code>: If the metrics are exposed on a different port</li>
</ul>

<p>And yes you need to expose the port with metrics to the service so Prometheus could access it</p>
