0
votes

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: https://github.com/helm/charts/tree/master/stable/prometheus-postgres-exporter And filled values.yaml with my database info. After installing, it provided me with the instruction below:

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

But when I try to forward the port, I got connection refused:

Handling connection for 8080
E0801 19:51:02.781508   22099 portforward.go:331] an error occurred forwarding 8080 -> 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

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

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 -> 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"

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

1

1 Answers

2
votes

time="2018-08-02T01:08:46Z" level=info msg="Starting Server: :9187" source="postgres_exporter.go:1137"

It looks like the chart notes text just has a copy-paste error, since the port number is not :80 but rather :9187, which is great because it squares with the postgresql exporter port in their registry.

So, it should be:

kubectl port-forward 9187:9187 &
sleep 2
curl localhost:9187/metrics