得到错误“获得http:// localhost:9443 / metrics:拨打tcp 127.0.0.1:9443:connect:连接被拒绝”; [英] Getting error "Get http://localhost:9443/metrics: dial tcp 127.0.0.1:9443: connect: connection refused"

查看:809
本文介绍了得到错误“获得http:// localhost:9443 / metrics:拨打tcp 127.0.0.1:9443:connect:连接被拒绝”;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Hyperledger fabric v1.4网络配置Prometheus和Grafana,以分析对等和链码mertics。在执行以下 9443 映射到主机的端口 9443 。 //hyperledger-fabric.readthedocs.io/en/latest/operations_service.html#peer rel = noreferrer>文档。我还已将提供商项更改为度量标准 prometheus 对等方 core.yml 中的>部分。我已经按照以下方式在 docker-compose.yml 中配置了普罗米修斯和格拉芬纳。

 普罗米修斯:
映像:prom / prometheus:v2.6.1
container_name:普罗米修斯
卷:
-./prometheus/:/etc/prometheus/
-prometheus_data:/ prometheus
命令:
-'--config.file = / etc / prometheus / prometheus.yml'
-'--storage.tsdb.path = / prometheus '
-'--web.console.libraries = / etc / prometheus / console_libraries'
-'--web.console.templates = / etc / prometheus / consoles'
-'- -storage.tsdb.retention = 200h'
-'--web.enable-lifecycle'
重新启动:除非已停止
端口:
-9090:9090
网络:
-基本的
标签:
org.label-schema.group:监控

grafana:
图片:grafana / grafana:5.4 .3
容器名称:grafana
卷:
-grafana_data:/ var / lib / grafana
-./grafana/datasources:/e tc / grafana /数据源
-./grafana/dashboards:/etc/grafana/dashboards
-./grafana/setup.sh:/setup.sh
入口点:/setup.sh
环境:
-GF_SECURITY_ADMIN_USER = {ADMIN_USER}
-GF_SECURITY_ADMIN_PASSWORD = {ADMIN_PASS}
-GF_USERS_ALLOW_SIGN_UP = false
重新启动:除非停止的
端口:
-3000:3000
网络:
-基本
标签:
org.label-schema.group:监视

当我在远程centos机器上 curl 0.0.0.0:9443/metrics 时,我得到了所有指标列表。但是,当我使用上述配置运行Prometheus时,它引发错误获取http:// localhost:9443 / metrics:拨打tcp 127.0.0.1:9443:connect:连接被拒绝。这就是我的 prometheus.yml 的样子。

  global:
scrape_interval:15s
评价间隔:15s

scrape_configs:
-job_name:'prometheus'
scrape_interval:10s
static_configs:
-目标:['localhost:9090']

-job_name:'peer_metrics'
scrape_interval:10s
static_configs:
-目标:['localhost:9443' ]

即使当我转到端点 http:// localhost:9443 / metrics 在我的浏览器中,我获得了所有指标。我在这里做错了什么。

解决方案

由于目标不在Prometheus容器内运行,因此Prometheus指标如何显示在其接口上而不是同级接口上?无法通过本地主机访问它们。您需要通过主机专用IP或通过将 localhost 替换为 docker.for.mac.localhost

I'm trying to configure Prometheus and Grafana with my Hyperledger fabric v1.4 network to analyze the peer and chaincode mertics. I've mapped peer container's port 9443 to my host machine's port 9443 after following this documentation. I've also changed the provider entry to prometheus under metrics section in core.yml of peer. I've configured prometheus and grafana in docker-compose.yml in the following way.

  prometheus:
    image: prom/prometheus:v2.6.1
    container_name: prometheus
    volumes:
    - ./prometheus/:/etc/prometheus/
    - prometheus_data:/prometheus
    command:
    - '--config.file=/etc/prometheus/prometheus.yml'
    - '--storage.tsdb.path=/prometheus'
    - '--web.console.libraries=/etc/prometheus/console_libraries'
    - '--web.console.templates=/etc/prometheus/consoles'
    - '--storage.tsdb.retention=200h'
    - '--web.enable-lifecycle'
    restart: unless-stopped
    ports:
    - 9090:9090
    networks:
    - basic
    labels:
    org.label-schema.group: "monitoring"

  grafana:
    image: grafana/grafana:5.4.3
    container_name: grafana
    volumes:
    - grafana_data:/var/lib/grafana
    - ./grafana/datasources:/etc/grafana/datasources
    - ./grafana/dashboards:/etc/grafana/dashboards
    - ./grafana/setup.sh:/setup.sh
    entrypoint: /setup.sh
    environment:
    - GF_SECURITY_ADMIN_USER={ADMIN_USER}
    - GF_SECURITY_ADMIN_PASSWORD={ADMIN_PASS}
    - GF_USERS_ALLOW_SIGN_UP=false
    restart: unless-stopped
    ports:
    - 3000:3000
    networks:
    - basic
    labels:
    org.label-schema.group: "monitoring"

When I curl 0.0.0.0:9443/metrics on my remote centos machine, I get all the list of metrics. However, when I run Prometheus with the above configuration, it throws the error Get http://localhost:9443/metrics: dial tcp 127.0.0.1:9443: connect: connection refused. This is what my prometheus.yml looks like.

global:
  scrape_interval:     15s
  evaluation_interval: 15s

scrape_configs:
  - job_name: 'prometheus'
    scrape_interval: 10s
    static_configs:
      - targets: ['localhost:9090']

  - job_name: 'peer_metrics'
    scrape_interval: 10s
    static_configs:
      - targets: ['localhost:9443']

Even, when I go to endpoint http://localhost:9443/metrics in my browser, I get all the metrics. What am I doing wrong here. How come Prometheus metrics are being shown on its interface and not peer's?

解决方案

Since the targets are not running inside the prometheus container, they cannot be accessed through localhost. You need to access them through the host private IP or by replacing localhost with docker.for.mac.localhost

这篇关于得到错误“获得http:// localhost:9443 / metrics:拨打tcp 127.0.0.1:9443:connect:连接被拒绝”;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆