【发布时间】:2019-11-25 12:19:43
【问题描述】:
尝试使用 Prometheus 服务器获取指标 我使用的yaml是
global:
scrape_interval: 5s
scrape_configs:
- job_name: 'student'
metrics_path: '/student/actuator/prometheus'
static_configs:
- targets: ['<HOST IP>:8080']
我用来运行docker文件的命令
docker run -d -p 9090:9090 -v <prometheus.yml location>:/etc/prometheus/prometheus.yml prom/prometheus --config.file=/etc/prometheus/prometheus.yml
我在 Prometheus 仪表板中遇到的错误
Get http://<host ip>:8080/student/actuator/prometheus: context deadline exceeded
【问题讨论】:
-
“超出上下文期限”通常意味着 Prometheus 在连接到它试图抓取的主机时超时 - 你可以从 prometheus 容器中 curl/wget 主机吗?
-
我尝试使用 wget 无法连接
-
听起来你找到了问题所在。检查您的防火墙设置,如果 IP 是内部文档 IP,请检查它是否有效。
-
我通过在 docker 中传递 --net=host 作为参数解决了这个问题
-
我知道这有点晚了,但我今天在树莓派上运行 prom/node-exporter docker 容器时遇到了同样的问题。我的问题是防火墙。我在 UFW 中打开了端口,这解决了问题。