sofastack / sofa-lookout

SOFALookout is a light-weight monitoring and analysis tool
Apache License 2.0
372 stars 119 forks source link

Docker deployment failed (need more clear service dependency relationship description) #113

Open ActivePeter opened 5 months ago

ActivePeter commented 5 months ago

Describe the bug

Start the docker service failed as https://www.sofastack.tech/projects/sofa-lookout/quick-start-metrics-server/

Expected behavior

No error in log.

Actual behavior

Reaching the inner ip of the container, but es is run as another container.

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'selfMetricsStarter': Unsatisfied dependency expressed through field 'exportChainManager'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'exportManager' defined in class path resource [com/alipay/sofa/lookout/gateway/metrics/starter/MetricPipelineConfiguration.class]: Unsatisfied dependency expressed through method 'exportManager' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'esMetricsExportChain' defined in class path resource [com/alipay/sofa/lookout/gateway/metrics/exporter/es/spring/bean/config/EsExporterConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.alipay.sofa.lookout.gateway.core.prototype.exporter.chain.ExportChain]: Factory method 'esMetricsExportChain' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'esMetricsExporter' defined in class path resource [com/alipay/sofa/lookout/gateway/metrics/exporter/es/spring/bean/config/EsExporterConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.alipay.sofa.lookout.gateway.metrics.exporter.es.ESMetricExporter]: Factory method 'esMetricsExporter' threw exception; nested exception is java.lang.IllegalStateException: java.net.ConnectException: Failed to connect to es/172.19.0.2:9200

Steps to reproduce

docker-compose.yml

version: '3'
services:
  allinone:
    image: xzchaoo/lookout-allinone:1.6.0-SNAPSHOT
    container_name: allinone
    ports:
      - "7200:7200"
      - "9090:9090"
    volumes:
      - ./foo.properties:/home/admin/deploy/foo.properties
    environment:
      - JAVA_OPTS=-Dlookoutall.config-file=/home/admin/deploy/foo.properties
      # 如果您需要添加其他 JVM 系统属性,您可以通过在此处指定多个 JAVA_OPTS 环境变量来实现
    depends_on:
      - es
    # networks:
    #   - my_network
  es:
    image: elasticsearch:5.6
    container_name: es
    ports:
      - "9200:9200"
      - "9300:9300"
    environment:
      - "discovery.type=single-node"
    # networks:
    #   - my_network

foo.properties (replace the ip)

gateway.metrics.exporter.es.host=es
metrics-server.spring.data.jest.uri=http://192.168.31.87:9200

docker-compose up -d

Environment

ActivePeter commented 5 months ago

_allinone_logs.txt

nobodyiam commented 5 months ago

would you please try to replace the es below to the real ip?

gateway.metrics.exporter.es.host=192.168.31.87
metrics-server.spring.data.jest.uri=http://192.168.31.87:9200
ActivePeter commented 5 months ago

would you please try to replace the es below to the real ip?

gateway.metrics.exporter.es.host=192.168.31.87
metrics-server.spring.data.jest.uri=http://192.168.31.87:9200

image It seems the problem is still there.

ActivePeter commented 5 months ago
image

The es is available

nobodyiam commented 5 months ago
  1. It seems that 192.168.31.87 is the IP address of your computer, which currently isn't reachable from within the Docker container. There should be a network configuration that enables the Docker container to connect with the host.

  2. The Docker Compose documentation suggests that the es container ought to be accessible by the allinone container using the hostname es. This implies that there may be some configuration adjustments required to facilitate this connectivity.

ActivePeter commented 5 months ago

I have used an bridge network now, and I use a curl container to test the es in domain and ip.

The curl results:

image

The curl script:

sleep 10
curl http://es:9200
curl http://192.168.31.87:9200

They are both reachable.

However, the lookout container is still not ok.

image image

This is the new compose file

version: '3'
services:
  test_es:
    #curl
    image: appropriate/curl
    container_name: test_es
    # command: ["curl", "http://es:9200"]
    # multiple commands
    volumes:
      - ./curl.sh:/curl.sh
    command: sh /curl.sh
    depends_on:
      - es
    networks:
      - my_network

  allinone:
    image: xzchaoo/lookout-allinone:1.6.0-SNAPSHOT
    container_name: allinone
    ports:
      - "7200:7200"
      - "9090:9090"
    volumes:
      - ./foo.properties:/home/admin/deploy/foo.properties
    environment:
      - JAVA_OPTS=-Dlookoutall.config-file=/home/admin/deploy/foo.properties
      # 如果您需要添加其他 JVM 系统属性,您可以通过在此处指定多个 JAVA_OPTS 环境变量来实现
    depends_on:
      - es
    networks:
      - my_network
  es:
    image: elasticsearch:5.6
    container_name: es
    ports:
      - "9200:9200"
      - "9300:9300"
    environment:
      - "discovery.type=single-node"
    networks:
      - my_network

networks:
  my_network:
    driver: bridge
  1. It seems that 192.168.31.87 is the IP address of your computer, which currently isn't reachable from within the Docker container. There should be a network configuration that enables the Docker container to connect with the host.
  2. The Docker Compose documentation suggests that the es container ought to be accessible by the allinone container using the hostname es. This implies that there may be some configuration adjustments required to facilitate this connectivity.