2024년 5월 20일 월요일

services. Additional property annotations is not allowed

docker 컨테이너 로그 수집하기 위해 프로메테우스와 익스포터 설치중 에러

아래와 같이 컴포즈 파일 생성
  node-exporter:
    image: prom/node-exporter:latest
    container_name: node-exporter
    restart: unless-stopped
    labels:
      service.discovery.prometheus: "true"
   annotations:
    service.annotations.prometheus.io/scrape: "true"
    volumes:
      - /proc:/host/proc:ro
      - /sys:/host/sys:ro
      - /:/rootfs:ro
    command:
      - '--path.procfs=/host/proc'
      - '--path.rootfs=/rootfs'
      - '--path.sysfs=/host/sys'
      - '--collector.filesystem.mount-points-exclude=^/(sys|proc|dev|host|etc)($$|/)'
    expose:
      - '9100'
    networks:
      monitoring:
        aliases:
          - exporter
    deploy:
      mode: global
---------------------------------
컴포즈 버전 3.8 이전 이후 설정이 다르다.


For Docker Compose versions above 3.8:
YAML
node-exporter:
  image: prom/node-exporter:latest
  container_name: node-exporter
  restart: unless-stopped
  labels:
    service.discovery.prometheus: "true"
  annotations:
    service.annotations.prometheus.io/scrape: "true"


For Docker Compose versions below v3.8:

The annotations section isn't supported. You can achieve the same functionality using environment variables:

YAML
node-exporter:
  image: prom/node-exporter:latest
  container_name: node-exporter
  restart: unless-stopped
  labels:
    service.discovery.prometheus: "true"
  environment: 

- WEB_SCRAPE_TARGET=true # Adjust the variable name based on node-