version: "3.9"

configs:
  prometheus_config_v3:
    file: ./prometheus/prometheus.yml
  prometheus_rules_v3:
    file: ./prometheus/rules/vello.rules.yml
  alertmanager_config_v3:
    file: ./alertmanager/alertmanager.yml

volumes:
  prom_data:
  alertmanager_data:

services:
  prometheus:
    image: prom/prometheus:v2.52.0
    command:
      - "--config.file=/etc/prometheus/prometheus.yml"
      - "--storage.tsdb.path=/prometheus"
      - "--storage.tsdb.retention.time=15d"
      - "--web.enable-lifecycle"
    configs:
      - source: prometheus_config_v3
        target: /etc/prometheus/prometheus.yml
      - source: prometheus_rules_v3
        target: /etc/prometheus/rules/vello.rules.yml
    volumes:
      - prom_data:/prometheus
    networks:
      - monitoring
      - vello-overlay
    deploy:
      placement:
        constraints:
          - node.role == manager

  prometheus-alertmanager:
    image: prom/alertmanager:v0.27.0
    command:
      - "--config.file=/etc/alertmanager/alertmanager.yml"
      - "--storage.path=/alertmanager"
    configs:
      - source: alertmanager_config_v3
        target: /etc/alertmanager/alertmanager.yml
    volumes:
      - alertmanager_data:/alertmanager
    networks:
      - monitoring
    deploy:
      placement:
        constraints:
          - node.role == manager

  prometheus-node-exporter:
    image: quay.io/prometheus/node-exporter:v1.7.0
    deploy:
      mode: global
      placement:
        constraints:
          - node.platform.os == linux
    networks:
      - monitoring
    command:
      - "--path.procfs=/host/proc"
      - "--path.sysfs=/host/sys"
      - "--path.rootfs=/host"
    volumes:
      - /proc:/host/proc:ro
      - /sys:/host/sys:ro
      - /:/host:ro

networks:
  monitoring:
    driver: overlay
    attachable: true
  vello-overlay:
    external: true
    name: vello_vello-overlay
