Hyp*_*olf 1 docker grafana prometheus
主要目标是将 prometheus 链接为 grafana 中的后端,但http://localhost:9090作为 grafana 中的 url 返回输入HTTP Error Bad Gateway
我启动了一个 prometheus docker 镜像,但它没有监听 IPv4 上的 9090 端口。
netstat -ntulp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 15895/nginx: master
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 3190/sshd
tcp 0 0 127.0.0.1:5432 0.0.0.0:* LISTEN 24970/postmaster
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 3148/master
tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN 15895/nginx: master
tcp6 0 0 :::9100 :::* LISTEN 16652/node_exporter
tcp6 0 0 :::80 :::* LISTEN 15895/nginx: master
tcp6 0 0 :::22 :::* LISTEN 3190/sshd
tcp6 0 0 :::3000 :::* LISTEN 28436/docker-proxy
tcp6 0 0 ::1:5432 :::* LISTEN 24970/postmaster
tcp6 0 0 ::1:25 :::* LISTEN 3148/master
tcp6 0 0 :::9090 :::* LISTEN 31648/docker-proxy
udp 0 0 0.0.0.0:68 0.0.0.0:* 2806/dhclient
udp 0 0 127.0.0.1:323 0.0.0.0:* 1639/chronyd
udp6 0 0 ::1:323 :::* 1639/chronyd
Run Code Online (Sandbox Code Playgroud)
这是我的 docker 命令:
docker run -d -p 9090:9090 --name prometheus -v /etc/prometheus.yml:/etc/prometheus/prometheus.yml -v /mnt/vol-0001/prometheus_data/:/etc/prometheus/data prom/prometheus --log.level=debug
Run Code Online (Sandbox Code Playgroud)
我使用-p 9090:9090并-p 0.0.0.0:9090具有相同的结果
docker logs prometheus 返回:
level=info ts=2018-12-19T21:07:59.332452641Z caller=main.go:243 msg="Starting Prometheus" version="(version=2.6.0, branch=HEAD, revision=dbd1d58c894775c0788470944b818cc724f550fb)"
level=info ts=2018-12-19T21:07:59.332554622Z caller=main.go:244 build_context="(go=go1.11.3, user=root@bf5760470f13, date=20181217-15:14:46)"
level=info ts=2018-12-19T21:07:59.332584047Z caller=main.go:245 host_details="(Linux 3.10.0-957.1.3.el7.x86_64 #1 SMP Thu Nov 29 14:49:43 UTC 2018 x86_64 9dd3a9318064 (none))"
level=info ts=2018-12-19T21:07:59.332610547Z caller=main.go:246 fd_limits="(soft=65536, hard=65536)"
level=info ts=2018-12-19T21:07:59.332631287Z caller=main.go:247 vm_limits="(soft=unlimited, hard=unlimited)"
level=info ts=2018-12-19T21:07:59.334232116Z caller=main.go:561 msg="Starting TSDB ..."
level=info ts=2018-12-19T21:07:59.334671887Z caller=repair.go:48 component=tsdb msg="found healthy block" mint=1545204931123 maxt=1545220800000 ulid=01CZ3PHTVQQTW7Q122X7Y15WV4
level=info ts=2018-12-19T21:07:59.334756938Z caller=repair.go:48 component=tsdb msg="found healthy block" mint=1545242400000 maxt=1545249600000 ulid=01CZ44997810VTYP3GV0KJXXN1
level=info ts=2018-12-19T21:07:59.334819198Z caller=repair.go:48 component=tsdb msg="found healthy block" mint=1545220800000 maxt=1545242400000 ulid=01CZ4499ASP4RG8BPR8PE5WAKY
level=info ts=2018-12-19T21:07:59.346244745Z caller=web.go:429 component=web msg="Start listening for connections" address=0.0.0.0:9090
level=info ts=2018-12-19T21:07:59.461554488Z caller=main.go:571 msg="TSDB started"
level=info ts=2018-12-19T21:07:59.461625871Z caller=main.go:631 msg="Loading configuration file" filename=prometheus.yml
level=debug ts=2018-12-19T21:07:59.462558422Z caller=manager.go:213 component="discovery manager scrape" msg="Starting provider" provider=string/0 subs=[prometheus]
level=info ts=2018-12-19T21:07:59.462601563Z caller=main.go:657 msg="Completed loading of configuration file" filename=prometheus.yml
level=info ts=2018-12-19T21:07:59.462615458Z caller=main.go:530 msg="Server is ready to receive web requests."
level=debug ts=2018-12-19T21:07:59.462669264Z caller=manager.go:231 component="discovery manager scrape" msg="discoverer channel closed" provider=string/0
Run Code Online (Sandbox Code Playgroud)
我还尝试禁用防火墙以确保它不是造成这种头痛的原因。
我不是 docker/kubernetes 专家,感谢您的帮助。
在localhost您提到在Grafana数据源输入它的Grafana容器本身,因为Grafana内部做出决议localhost为127.0.0.1:可能是因为你正在使用的GUI你期待的查询是通过AJAX /前端的呼叫发出,但不,这一切都在后台支持.
让甚至使用 Docker Compose 与使用Networks连接容器的服务编排容器:
# docker-compose.yaml
version: "3"
services:
grafana:
image: grafana/grafana:5.4.1
ports:
- 3000:3000
prometheus:
image: prom/prometheus:v2.5.0
Run Code Online (Sandbox Code Playgroud)
在docker-compose up -d您可以在端口上访问您的 Docker 机器 IP(或localhost,如果运行 Docker for Mac),:3000然后将 Prometheus 数据源 URL 设置为http://prometheus:9090,它就会工作!
| 归档时间: |
|
| 查看次数: |
1865 次 |
| 最近记录: |