首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Post http://localhost:9093/api/v1/alerts:拨号tcp [::1]:9093: connect:连接被拒绝

Post http://localhost:9093/api/v1/alerts:拨号tcp [::1]:9093: connect:连接被拒绝
EN

Stack Overflow用户
提问于 2018-11-15 15:50:36
回答 2查看 2.3K关注 0票数 0

我在k8s集群中的同一个pod上启动了prometheus和alertmanager,两个容器都正常启动,但是我发现prometheus无法向start管理器发送post请求,为什么?

论普罗米修斯容器

代码语言:javascript
运行
复制
level=info ts=2018-11-15T07:02:02.147783133Z caller=main.go:238 msg="Starting Prometheus" version="(version=2.4.3, branch=HEAD, revision=167a4b4e73a8eca8df648d2d2043e21bdb9a7449)"
level=info ts=2018-11-15T07:02:02.147861401Z caller=main.go:239 build_context="(go=go1.11.1, user=root@1e42b46043e9, date=20181004-08:42:02)"
level=info ts=2018-11-15T07:02:02.147879439Z caller=main.go:240 host_details="(Linux 3.10.0-693.17.1.el7.x86_64 #1 SMP Thu Jan 25 20:13:58 UTC 2018 x86_64 k8s-monitor-6d9cd9cd55-vzlmq (none))"
level=info ts=2018-11-15T07:02:02.147895594Z caller=main.go:241 fd_limits="(soft=1048576, hard=1048576)"
level=info ts=2018-11-15T07:02:02.147908172Z caller=main.go:242 vm_limits="(soft=unlimited, hard=unlimited)"
level=info ts=2018-11-15T07:02:02.151206196Z caller=main.go:554 msg="Starting TSDB ..."
level=info ts=2018-11-15T07:02:02.151347322Z caller=web.go:397 component=web msg="Start listening for connections" address=0.0.0.0:9090
level=info ts=2018-11-15T07:02:02.15948818Z caller=main.go:564 msg="TSDB started"
level=info ts=2018-11-15T07:02:02.159530481Z caller=main.go:624 msg="Loading configuration file" filename=/opt/prometheus-2.4.3.linux-amd64/prometheus.yml
level=info ts=2018-11-15T07:02:02.164675684Z caller=main.go:650 msg="Completed loading of configuration file" filename=/opt/prometheus-2.4.3.linux-amd64/prometheus.yml
level=info ts=2018-11-15T07:02:02.16470252Z caller=main.go:523 msg="Server is ready to receive web requests."
level=error ts=2018-11-15T07:02:02.165912877Z caller=notifier.go:473 component=notifier alertmanager=http://localhost:9093/api/v1/alerts count=0 msg="Error sending alert" err="Post http://localhost:9093/api/v1/alerts: dial tcp [::1]:9093: connect: connection refused"

在alertmanager容器上

代码语言:javascript
运行
复制
level=info ts=2018-11-15T07:02:02.498442497Z caller=main.go:174 msg="Starting Alertmanager" version="(version=0.15.2, branch=HEAD, revision=d19fae3bae451940b8470abb680cfdd59bfa7cfa)"
level=info ts=2018-11-15T07:02:02.498524847Z caller=main.go:175 build_context="(go=go1.10.3, user=root@3101e5b68a55, date=20180814-10:53:39)"
level=info ts=2018-11-15T07:02:02.505830622Z caller=cluster.go:155 component=cluster msg="setting advertise address explicitly" addr=192.168.216.185 port=9094
level=info ts=2018-11-15T07:02:02.50851545Z caller=main.go:322 msg="Loading configuration file" file=/opt/alertmanager/alertmanager.yml
level=info ts=2018-11-15T07:02:02.508720329Z caller=cluster.go:570 component=cluster msg="Waiting for gossip to settle..." interval=2s
level=info ts=2018-11-15T07:02:02.512111679Z caller=main.go:398 msg=Listening address=:9093
level=info ts=2018-11-15T07:02:04.508881502Z caller=cluster.go:595 component=cluster msg="gossip not settled" polls=0 before=0 now=1 elapsed=2.000097885s
level=info ts=2018-11-15T07:02:12.50938298Z caller=cluster.go:587 component=cluster msg="gossip settled; proceeding" elapsed=10.000595281s

在pod中

代码语言:javascript
运行
复制
[root@k8s-monitor-6d9cd9cd55-vzlmq /]# netstat -utlpn
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp6       0      0 :::9090                 :::*                    LISTEN      5/prometheus
tcp6       0      0 :::9093                 :::*                    LISTEN      -
tcp6       0      0 :::9094                 :::*                    LISTEN      -
udp6       0      0 :::9094                 :::*                                -
EN

回答 2

Stack Overflow用户

发布于 2021-02-04 03:07:02

删除端口号周围的“为我解决了这个问题

票数 1
EN

Stack Overflow用户

发布于 2020-07-11 00:04:25

我使用docker-compose进行测试,也遇到了同样的问题。

代码语言:javascript
运行
复制
[compose.yaml]
prometeus:
  image: prom/prometheus:master
  networks: [ test ]
  hostname: prometeus
  ports:
   - 9090:9090
alertmanager:
  image: prom/alertmanager:master
  networks: [ test ]
  hostname: alertmanager
  ports:
    - "9093:9093"

prometeus.yml
alerting:
  alertmanagers:
    - static_configs:
      - targets: ['alertmanager:9093', `'127.0.0.1:9093', 'localhost:9093'`]

在使用127.0.0.1localhost时,我收到了错误,但更改为HOSTNAME帮助我解决了这个问题。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/53314642

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档