无法访问安装在 kubernetes 中的 Prometheus Postgres 导出器:连接被拒绝
Can't access Prometheus Postgres exporter installed in kubernetes: connection refused
我正在尝试使用 prometheus 在 kubernetes 中进行监控。我们有一些指标存储在外部 postgres 数据库中,所以首先我想安装一个 postgres 导出器。我使用这个 helm chart 来安装它:https://github.com/helm/charts/tree/master/stable/prometheus-postgres-exporter
并用我的数据库信息填充 values.yaml。安装后,它为我提供了以下说明:
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
但是当我尝试转发端口时,连接被拒绝:
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
然而,当我执行 kubectl describe 时,pod 工作正常,并且那里只有三个日志:
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"
为了让它正常工作并能够通过端口转发查看指标,我是否遗漏了什么?
time="2018-08-02T01:08:46Z" level=info msg="Starting Server: :9187" source="postgres_exporter.go:1137"
它看起来像他们注册表中的 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。
所以,应该是:
kubectl port-forward 9187:9187 &
sleep 2
curl localhost:9187/metrics
我正在尝试使用 prometheus 在 kubernetes 中进行监控。我们有一些指标存储在外部 postgres 数据库中,所以首先我想安装一个 postgres 导出器。我使用这个 helm chart 来安装它:https://github.com/helm/charts/tree/master/stable/prometheus-postgres-exporter 并用我的数据库信息填充 values.yaml。安装后,它为我提供了以下说明:
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
但是当我尝试转发端口时,连接被拒绝:
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
然而,当我执行 kubectl describe 时,pod 工作正常,并且那里只有三个日志:
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"
为了让它正常工作并能够通过端口转发查看指标,我是否遗漏了什么?
time="2018-08-02T01:08:46Z" level=info msg="Starting Server: :9187" source="postgres_exporter.go:1137"
它看起来像他们注册表中的 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。
所以,应该是:
kubectl port-forward 9187:9187 &
sleep 2
curl localhost:9187/metrics