version: '3.5'
services:
  #cpu、内存、硬盘、网络监控
  basic:
    image: registry.edoc2.com:5000/edoc2v5/metricbasic:ecm-region-apm-YiJinZhi-v5.18.0.15
    user: root
    volumes:
      - type: bind
        source: /proc
        target: /hostfs/proc
        read_only: true
      - type: bind
        source: /sys/fs/cgroup
        target: /hostfs/sys/fs/cgroup
        read_only: true
      - type: bind
        source: /
        target: /hostfs
        read_only: true
      - type: bind
        source: /var/run/docker.sock
        target: /var/run/docker.sock
        read_only: true
    deploy:
      mode: global
      restart_policy:
        condition: on-failure
    networks:
      - hostnet
    logging:
      driver: "json-file"
      options:
        max-size: "2000k"
        max-file: "10"

  #监控检查
  heartbeat:
    hostname: heartbeat
    image: registry.edoc2.com:5000/edoc2v5/heartbeat:ecm-region-apm-YiJinZhi-v5.18.0.15
    environment:
      - MONITORS_ICMP_HOSTS=["edoc2","nginx","content","transport","es"]
      - MONITORS_HTTP_HOSTS=["http://edoc2/api/values"]
      - ELASTICSEARCH_HOSTS=es:9200
    networks: 
      - macrowing
    deploy:
      placement:
        constraints:
          - node.labels.isapm == true
      replicas: 1
      restart_policy:
        condition: on-failure
    logging:
      driver: "json-file"
      options:
        max-size: "2000k"
        max-file: "10"

  filebeat:
    hostname: filebeat
    image: registry.edoc2.com:5000/edoc2v5/filebeat:ecm-region-apm-YiJinZhi-v5.18.0.15
    environment:
      - ELASTICSEARCH_HOSTS=es:9200
    volumes:
      - /var/log/:/hostfs/var/log/
      - /tmp:/usr/share/filebeat/data
    networks: 
      - macrowing
    deploy:
      mode: global
      restart_policy:
        condition: on-failure
    logging:
      driver: "json-file"
      options:
        max-size: "2000k"
        max-file: "10"

  #中间件监控
  middleware:
    hostname: middleware
    image: registry.edoc2.com:5000/edoc2v5/metricmiddle:ecm-region-apm-YiJinZhi-v5.18.0.15
    environment:
      # redis监控
      #- REDIS_ENABLED=true
      #- REDIS_HOSTS=[redis:6379]
      # es监控
      - ES_ENABLED=true
      - ES_HOSTS=[http://es:9200]
      # 数据输出es地址
      - ELASTICSEARCH_HOSTS=es:9200
    networks: 
      - macrowing
    deploy:
      placement:
        constraints:
          - node.labels.isapm == true
      replicas: 1
      restart_policy:
        condition: on-failure
    logging:
      driver: "json-file"
      options:
        max-size: "2000k"
        max-file: "10"

  #日志收集
  logstash:
    hostname: logstash
    image: registry.edoc2.com:5000/edoc2v5/logstash:ecm-region-apm-YiJinZhi-v5.18.0.15
    environment:
      - REGION=subregion
      - LS_JAVA_OPTS=-Xms2g -Xmx2g
    ports:
      - "55514:55514/udp"
    deploy:
      placement:
        constraints:
          - node.labels.isapm == true
      replicas: 1
      restart_policy:
        condition: on-failure
    networks:
      - macrowing
    logging:
      driver: "json-file"
      options:
        max-size: "2000k"
        max-file: "10"

  es:
    image: registry.edoc2.com:5000/edoc2v5/elasticsearch:ecm-region-apm-YiJinZhi-v5.18.0.15
    hostname: es
    volumes:
      - /home/edoc2/macrowing/edoc2v5/data/es:/esdata
    networks:
      - macrowing
    environment:
      - node.name=es
      - ES_JAVA_OPTS=-Xmx2g -Xms2g
    deploy:
      replicas: 1
      placement:
        constraints:
          - node.labels.isapm == true
      restart_policy:
        condition: on-failure
    logging:
      driver: "json-file"
      options:
        max-size: "2048k"
        max-file: "10"

  proxy:
    hostname: proxy
    image: registry.edoc2.com:5000/edoc2v5/nginx:ecm-region-apm-YiJinZhi-v5.18.0.15
    command: /etc/nginx/proxy.sh
    environment:
      - MIDDLEWARE=standalone
      - PROXY_SERVICES=es
    ports:
      - "30003:30003"
    deploy:
      replicas: 1
      placement:
        constraints:
          - node.labels.isapm == true
      restart_policy:
        condition: on-failure
    networks:
      - macrowing
    logging:
      driver: "json-file"
      options:
        max-size: "2000k"
        max-file: "10"

networks:
  hostnet:
    external: true
    name: host
  macrowing:
    external: true
    name: macrowing
