普罗米修斯指标终结点正在运行,但目标状态为关闭 [英] Prometheus metrics end point is running but the target status is down

查看:12
本文介绍了普罗米修斯指标终结点正在运行,但目标状态为关闭的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在http://localhost:9615/metrics上运行了Prometheus Polkadot指标端点 我已经在配置中定义了prometheus.yml

global:
  scrape_interval: 15s
  evaluation_interval: 15s

rule_files:
  # - "first.rules"
  # - "second.rules"

scrape_configs:
  - job_name: "prometheus"
    scrape_interval: 5s
    static_configs:
      - targets: ["localhost:9090"]
  - job_name: "substrate_node"
    scrape_interval: 5s
    static_configs:
      - targets: ["localhost:9615"]

我在目标中遇到以下错误

获取http://localhost:9615/metrics";:拨号TCP127.0.0.1:9615:连接: 连接被拒绝

我的普罗米修斯在码头容器内运行

docker run -d --name prometheus -p 9090:9090 -v prometheus.yml:/etc/prometheus/prometheus.yml prom/prometheus --config.file=/etc/prometheus/prometheus.yml

如何解决该错误?

推荐答案

为了在两个容器之间通信,您会希望它们位于同一Docker网桥网络中。否则,一个容器的本地主机版本将与另一个完全隔离。

若要解决此问题,请尝试使用容器名称而不是localhost在同一docker-compose.yaml中运行两个容器。

默认情况下,Compose会为您的应用程序设置一个网络。服务的每个容器都加入默认网络,并且既可以由该网络上的其他容器访问,也可以由它们在与容器名称相同的主机名处发现。

version: '2'

services:
  polkadot:
    container_name: polkadot
    image: parity/polkadot
    ports:
      - 30333:30333 # p2p port
      - 9933:9933 # rpc port
      - 9944:9944 # ws port
      - 9615:9615
    command: [
      "--name", "PolkaDocker",
      "--ws-external",
      "--rpc-external",
      "--rpc-cors", "all",
      "--prometheus-external"
    ]

  prometheus:
    container_name: prometheus
    image: prom/prometheus
    ports:
      - 9090:9090
    volumes:
      - ./prometheus.yml:/etc/prometheus/prometheus.yml
    command: [
      "--config.file=/etc/prometheus/prometheus.yml"
    ]

同样,您需要在Prometheus配置中更新命中的主机,如下所示:

global:
  scrape_interval: 15s
  evaluation_interval: 15s

rule_files:
  # - "first.rules"
  # - "second.rules"

scrape_configs:
  - job_name: "prometheus"
    scrape_interval: 5s
    static_configs:
      - targets: ["prometheus:9090"] # NOTE HOW ITS NOT LOCALHOST HERE
  - job_name: "substrate_node"
    scrape_interval: 5s
    static_configs:
      - targets: ["polkadot:9615"] # NOTE HOW ITS NOT LOCALHOST HERE

您可以在他们的文档here中找到大量关于Docker网络的错综复杂的资源。但上面的配置应该会让您启动并运行,因为这两个目标都是在我这一端的普罗米修斯中出现的。

这篇关于普罗米修斯指标终结点正在运行,但目标状态为关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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