version: '3.8'

networks:
  grafana_network:
    driver: overlay
    attachable: true

configs:
  prometheus_config:
    external: true

volumes:
  prometheus_data:
    driver_opts:
      type: nfs
      o: addr=dockerstorage,nfsvers=4
      device: :/grafana_tmp_data/prometheus

  grafana_data:
    driver_opts:
      type: nfs
      o: addr=dockerstorage,nfsvers=4
      device: :/grafana_tmp_data/grafana

  loki_data:
    driver_opts:
      type: nfs
      o: addr=dockerstorage,nfsvers=4
      device: :/grafana_tmp_data/loki



services:

# loki:
#   image: grafana/loki:2.6.1
#   user: "0:0"
#   volumes:
#     - loki_data:/loki
#   ports:
#     - "3100:3100"
#   command: -config.file=/etc/loki/local-config.yaml

#  promtail:
#    image: grafana/promtail:2.6.1
#    user: "0:0"
#    volumes:
#      - /var/log:/var/log
#    command: -config.file=/etc/promtail/config.yml

  prometheus:
#    user: "0:0"
    hostname: prometheus
    image: prom/prometheus
    environment:
      - TZ=Europe/Berlin #change Time Zone if needed
    configs:
      - source: prometheus_config
        target: /etc/prometheus/prometheus.yml
    volumes:
      - prometheus_data:/prometheus
    command:
      - '--config.file=/etc/prometheus/prometheus.yml'
    networks:
      - grafana_network
    ports:
      - 9090:9090
    deploy:
      placement:
        constraints: [node.labels.isDNS == false]

  grafana:
#   user: "0:0"
    hostname: grafana
    image: grafana/grafana
    environment:
      - TZ=Europe/Amsterdam
#    configs:
#      - source: grafana_config
#        target: /etc/grafana/grafana.ini
    volumes:
      - grafana_data:/var/lib/grafana
    networks:
      - grafana_network
    ports:
      - 3300:3000
    deploy:
      placement:
        constraints: [node.labels.isDNS == false]


  node-exporter:
    image: prom/node-exporter:latest
    deploy:
      mode: global
    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)($$|/)'
    networks:
      - grafana_network
    ports:
      - "9100:9100"
    deploy:
      mode: global

  tado-exporter:
    image: registry.vbchaos.nl/tado-exporter:arm64
    hostname: tado-exporter
    environment:
      EXPORTER_USERNAME: matthias.mitscherlich@gmail.com
      EXPORTER_PASSWORD: 14Mai1984
    networks:
      - grafana_network
    ports:
      - "9898:9898"
    deploy:
      placement:
        constraints: [node.labels.isDNS == false]
        
