普罗米修斯无法从本地主机访问指标
prometheus is not able to access metrics from localhost
我一直在尝试配置 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 相同。
因为您正在使用 docker-compose,因此 localhost
或 127.0.0.1
在 docker容器。
您可以将localhost
替换为您的机器IP或使用ngrok正如您所做的那样,docker 可以解析 到您的 IP。
感谢阅读:D
我一直在尝试配置 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 相同。
因为您正在使用 docker-compose,因此 localhost
或 127.0.0.1
在 docker容器。
您可以将localhost
替换为您的机器IP或使用ngrok正如您所做的那样,docker 可以解析 到您的 IP。
感谢阅读:D