简体   繁体   English

上下文截止日期已延长-prometheus-在docker上运行时

[英]context deadline extended - prometheus - while running on docker

I'm trying to get a spring microservice to regsiter on Prometheus. 我试图在Prometheus上获得春季微服务作为注册人。 Both are running on docker. 两者都在docker上运行。 I get "context deadline exceeded" in the Prometheus UI for my service. 我在Prometheus用户界面中获得“超出上下文截止日期”的服务。

Funnily, when i try to open "localhost:8081/metrics" in a new tab, it shows the metrics. 有趣的是,当我尝试在新标签中打开“ localhost:8081 / metrics”时,它会显示指标。

This is my docker-compose.yml. 这是我的docker-compose.yml。 This issue seems pretty common but I've not come across a solution that works for me ; 这个问题似乎很普遍,但是我并没有遇到适合我的解决方案; yet. 然而。

docker-compose.yml docker-compose.yml

version: '2.1'
networks:
   cadrs:
     ipam:
       config:
          - subnet: 172.28.0.0/16

services:
prometheus:
    image: prom/prometheus:0.18.0
    volumes:
        - ./prometheus.yml:/etc/prometheus/prometheus.yml
    command:
        - '-config.file=/etc/prometheus/prometheus.yml'
    ports:
        - '9090:9090'

demo:
    build: "C:/Users/hmt843/Downloads/demo"
    hostname: "demo"
    ports:
        - "8081:8081"
    networks:
       cadrs:
          ipv4_address: 172.28.1.2
node-exporter:
    image: prom/node-exporter:v0.15.0
    ports:
        - '9100:9100'

prometheus.yml 普罗米修斯

global:
  scrape_interval: 15s
  external_labels:
        monitor: 'my-monitor'

scrape_configs:
    - job_name: 'prometheus'
      target_groups:
          - targets: ['localhost:9090']
    - job_name: 'demo'
      tls_config:
        insecure_skip_verify: true
      target_groups:
          - targets: ['172.28.1.2:8081']
    - job_name: 'node-exporter'
      target_groups:
          - targets: ['node-exporter:9100']

By specifying the network section in your app's service the container is placed in a separate docker network called cadrs . 通过在您应用的服务中指定网络部分,可以将容器放置在一个名为cadrs的单独的cadrs网络中。 Your Prometheus service has no such network definition and thus is in the default network. 您普罗米修斯服务有没有这样的网络定义,因此在default网络。 Containers must reside in at least one common network to be able to access each others. 容器必须驻留在至少一个公共网络中,才能相互访问。 Even exposing the container on the host port doesn't affect this (but you could reach the app via your host ip - don't do this). 即使将容器暴露在主机端口上也不会对此造成影响(但是您可以通过主机ip访问应用程序-请勿这样做)。

If you really need this network configuration, either add Prometheus to the same network by adding the same network section to your Prometheus service or introduce another network (eg monitoring ) that is used in both services. 如果您确实需要此网络配置,则可以通过将相同的网络部分添加到您的Prometheus服务中来将Prometheus添加到相同的网络中,或者引入两个服务中都使用的另一个网络(例如, monitoring )。 Alternatively you could also specify that your app is in the default network by adding one more line to your networks section of the app. 另外,您还可以通过在应用程序的“网络”部分添加一行来指定您的应用程序在默认网络中。

networks:
  cadrs:
    [...]
  default:

Reference: https://docs.docker.com/compose/networking/#configure-the-default-network 参考: https : //docs.docker.com/compose/networking/#configure-the-default-network

With this setup, you can modify your scrape configuration also back to demo:8081 . 有了这个设置,你可以修改你刮配置也回到demo:8081 Either way, ask yourself if you really want to use manage container addresses by yourself... 无论哪种方式,问问自己是否真的要自己使用管理容器地址...

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Docker swarm leave --force - 超出上下文截止日期 - Docker swarm leave --force - context deadline exceeded init docker swarm with docker machine: context deadline exceeded - init docker swarm with docker machine: context deadline exceeded Docker 错误“无法连接到网络<name> : 超出上下文最后期限。”</name> - Docker error “Could not attach to network <name>: context deadline exceeded.” Prometheus不是在vm上运行,而是在本地Docker上运行 - Prometheus not running on the vm but runs on Docker locally 如何在Docker容器中运行的Prometheus中保存数据? - How to persist data in Prometheus running in a Docker container? 如何访问在 aws multiContainer docker 中运行的 prometheus 仪表板? - How to access my prometheus dashboard which are running in aws multiContainer docker? 如何为运行多个 docker 网络的服务配置“全局”prometheus - How configure a "global" prometheus for services running multiple docker network Hyperledger Fabric-实例化链码时出错(尝试连接到本地对等点时出错:超出了上下文期限) - Hyperledger Fabric - Error while Instantiating chaincode (error trying to connect to local peer: context deadline exceeded) 如何将在 Docker 容器中运行的 Grafana 连接到在主机上运行的 Prometheus 数据源(在 Docker for Mac 上)? - How to connect Grafana running in a Docker container to a Prometheus data source running on the host machine (on Docker for Mac)? (Kubernetes + Docker)Skaffold 不断终止我的部署文件:错误:无法在 2m0s 内稳定:超出上下文期限 - (Kubernetes + Docker) Skaffold keeps terminating my deployment files : Error: could not stabilize within 2m0s: context deadline exceeded
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM