【发布时间】:2020-06-25 13:34:27
【问题描述】:
我一直在尝试配置 prometheus 以在 grafana 中为我的 nodejs 应用程序显示指标。对于指标,我使用的是 prom-client。但是,在本地主机上,我总是收到以下错误:
Get http://localhost:5000/metrics: dial tcp 127.0.0.1:5000: connect: connection refused
此外,如果我使用本地隧道服务,例如 ngrok,它将能够读取指标。我错过了什么?我需要在某处添加一些特殊配置吗?
这是我的 prometheus.yml 文件:
global:
scrape_interval: 5s
external_labels:
monitor: 'my-monitor'
scrape_configs:
- job_name: 'prometheus'
static_configs:
- targets: ['localhost:9090']
- job_name: 'my-app'
static_configs:
- targets: ['localhost:5000']
我正在使用 docker-compose 运行默认的 prometheus 映像,对于 grafana 也是如此。
【问题讨论】:
-
你确定你的应用在 localhost:5000 上监听吗?尝试使用 0.0.0.0:5000。
-
@radar 相同的输出
-
你能发布你完整的 docker-compose 文件吗?应用程序是否在它自己的容器中运行?还是在主机上?
标签: node.js docker-compose prometheus