【问题标题】:Can't access Prometheus Postgres exporter installed in kubernetes: connection refused无法访问安装在 kubernetes 中的 Prometheus Postgres 导出器:连接被拒绝
【发布时间】:2018-08-02 03:01:36
【问题描述】:

我试图在 Kubernetes 中使用 prometheus 进行监控。我们有一些指标存储在外部 postgres 数据库中,所以首先我想安装一个 postgres 导出器。我用这个舵图来安装它: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"

我在这里是否缺少任何东西来使其正常工作并能够通过端口转发查看指标?

【问题讨论】:

    标签: postgresql kubernetes prometheus kubernetes-helm


    【解决方案1】:

    time="2018-08-02T01:08:46Z" level=info msg="启动服务器: :9187" source="postgres_exporter.go:1137"

    看起来chart notes text 只是有一个复制粘贴错误,因为端口号不是:80,而是:9187,这很好,因为它与注册表中的postgresql exporter port 一致。

    所以,应该是:

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

    【讨论】:

    • 哦,我的错,我没注意到。因为它有端口:80 和目标端口:9187,我把它们弄乱了。谢谢!!!!!!
    猜你喜欢
    • 1970-01-01
    • 2021-12-16
    • 2019-04-14
    • 2017-10-05
    • 1970-01-01
    • 2020-03-19
    • 1970-01-01
    • 2019-02-20
    • 1970-01-01
    相关资源
    最近更新 更多