Node.js+;普罗米修斯-目标下降连接被拒绝

Node.js+;普罗米修斯-目标下降连接被拒绝,node.js,prometheus,Node.js,Prometheus,我正在本地运行一个节点应用程序。它在http://localhost:3002使用prom客户端我可以在以下端点查看度量值 我把普罗米修斯放在一个码头集装箱里,并运行了它 Dockerfile FROM prom/prometheus ADD prometheus.yml /etc/prometheus/ 普罗米修斯.yml scrape_configs: - job_name: 'prometheus' scrape_interval: 5s static_config

我正在本地运行一个节点应用程序。它在
http://localhost:3002
使用prom客户端我可以在以下端点查看度量值

我把普罗米修斯放在一个码头集装箱里,并运行了它

Dockerfile

FROM prom/prometheus
ADD prometheus.yml /etc/prometheus/
普罗米修斯.yml

scrape_configs:
  - job_name: 'prometheus'
    scrape_interval: 5s

    static_configs:
      - targets: ['localhost:3002']
        labels:
          service: 'my-service'
          group: 'production'
rule_files:
  - 'alert.rules'

当我导航到
http://localhost:9090/targets
它显示

获取:拨打tcp 127.0.0.1:3002:连接: 拒绝连接


你能告诉我我做错了什么吗。节点应用程序正在该端口的本地主机上运行,因为当我转到
http://localhost:3002/metrics
我可以看到指标。

当您在容器中时,无法直接访问本地主机。您需要将docker.for.mac.localhost添加到prometheus.yml文件中。见下文:

你在prometheus.yml文件中的工作。 -工作名称:“普罗米修斯”

# metrics_path defaults to '/metrics'
# scheme defaults to 'http'.

static_configs:
- targets: ['localhost:9090']
- targets: ['docker.for.mac.localhost:3002']  

对于windows,它将是

- job_name: 'spring-actuator'
metrics_path: '/actuator/prometheus'
scrape_interval: 5s
static_configs:
  - targets: ['docker.for.win.localhost:8082']
- job_name: 'spring-actuator'
metrics_path: '/actuator/prometheus'
scrape_interval: 5s
static_configs:
  - targets: ['docker.for.win.localhost:8082']