<p>I was trying to use prometheus to do monitoring in kubernetes. We have some metrics stored in an external postgres database, so first I would like to install a postgres exporter. I used this helm chart to install it: <a href="https://github.com/helm/charts/tree/master/stable/prometheus-postgres-exporter" rel="nofollow noreferrer">https://github.com/helm/charts/tree/master/stable/prometheus-postgres-exporter</a>
And filled values.yaml with my database info. After installing, it provided me with the instruction below: </p>

<pre><code>NOTES:
1. Get the application URL by running these commands:
  export POD_NAME=$(kubectl get pods --namespace default -l "app=prometheus-postgres-exporter,release=veering-seastar" -o jsonpath="{.items[0].metadata.name}")
  echo "Visit http://127.0.0.1:8080 to use your application"
  kubectl port-forward $POD_NAME 8080:80
</code></pre>

<p>But when I try to forward the port, I got connection refused:</p>

<pre><code>Handling connection for 8080
E0801 19:51:02.781508   22099 portforward.go:331] an error occurred forwarding 8080 -&gt; 80: error forwarding port 80 to pod 37a502b22a15fefcbddd3907669a448c99e4927515fa6cdd6fd87ef774993b6b, uid : exit status 1: 2018/08/02 02:51:02 socat[32604] E connect(5, AF=2 127.0.0.1:80, 16): Connection refused
</code></pre>

<p>However the pod is working properly when I do kubectl describe, and there only three of logs there:</p>

<pre><code>time="2018-08-02T01:08:45Z" level=info msg="Established new database connection." source="postgres_exporter.go:995"
time="2018-08-02T01:08:45Z" level=info msg="Semantic Version Changed: 0.0.0 -&gt; 9.5.12" source="postgres_exporter.go:925"
time="2018-08-02T01:08:46Z" level=info msg="Starting Server: :9187" source="postgres_exporter.go:1137"
</code></pre>

<p>Is there anything I'm missing here to get it working and be able to see the metrics via port forwarding?</p>

Lavender
<blockquote>
  <p>time="2018-08-02T01:08:46Z" level=info msg="Starting Server: :9187" source="postgres_exporter.go:1137"</p>
</blockquote>

<p>It looks like the <a href="https://github.com/helm/charts/blob/master/stable/prometheus-postgres-exporter/templates/NOTES.txt#L13" rel="nofollow noreferrer">chart notes text</a> just has a copy-paste error, since the port number is not <code>:80</code> but rather <code>:9187</code>, which is great because it squares with the <a href="https://github.com/prometheus/prometheus/wiki/Default-port-allocations" rel="nofollow noreferrer">postgresql exporter port</a> in their registry.</p>

<p>So, it should be:</p>

<pre><code>kubectl port-forward 9187:9187 &amp;
sleep 2
curl localhost:9187/metrics
</code></pre>
