---
version: '3'

services:
  mon_prometheus:
    image: prom/prometheus:latest
    container_name: mon_prometheus
    restart: unless-stopped
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - /etc/timezone:/etc/timezone:ro
      - $PWD/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml
    depends_on:
      - mon_node-exporter
      - mon_cadvisor

  mon_node-exporter:
    image: prom/node-exporter:latest
    container_name: mon_node-exporter
    restart: unless-stopped
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - /etc/timezone:/etc/timezone:ro
      - /proc:/host/proc:ro
      - /sys:/host/sys:ro
      - /:/rootfs:ro
    command:
      - '--path.procfs=/host/proc'
      - '--path.sysfs=/host/sys'
      - '--path.rootfs=/rootfs'
      - '--collector.filesystem.ignored-mount-points="^(/rootfs|/host|)/(sys|proc|dev|host|etc)($$|/)"'
      - '--collector.filesystem.ignored-fs-types="^(sys|proc|auto|cgroup|devpts|ns|au|fuse\.lxc|mqueue)(fs|)$$"'

  mon_grafana:
    image: grafana/grafana:latest
    container_name: mon_grafana
    restart: unless-stopped
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - /etc/timezone:/etc/timezone:ro
      - /var/docker/data/monitoring/grafana:/var/lib/grafana
    ports:
      - 3000:3000
    user: "1000"  #  USER ID des Docker Users anpassen
    depends_on:
      - mon_prometheus
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.grafana.entrypoints=websecure"
      - "traefik.http.routers.grafana.rule=Host(`grafana.example.com`)"  # Domain anpassen
      - "traefik.http.routers.grafana.tls=true"
      - "traefik.http.routers.grafana.tls.certresolver=default"
      - "traefik.http.routers.grafana.middlewares=secHeaders@file"
      - "traefik.http.services.grafana.loadbalancer.server.port=3000"
    networks:
      - traefik_proxy
      - default

networks:
  traefik_proxy:
    external:
      name: traefik_proxy
  default:
    driver: bridge
