services:
  prometheus:
    image: prom/prometheus:latest
    container_name: prometheus_node${PROM_HOST_ID}
    restart: unless-stopped
    user: "1000:1000" # Matches your Gluster permissions
    command:
      - '--config.file=/etc/prometheus/prometheus.yml'
      - '--storage.tsdb.path=/prometheus'
      # CHANGED: Increased from 2h to 15d since Thanos is gone
      - '--storage.tsdb.retention.time=15d' 
      - '--web.enable-lifecycle' # Keeps API reload capability
    volumes:
      - /docker/prometheus/config:/etc/prometheus
      - /shared/prometheus/data:/prometheus
    ports:
      - "9090:9090"
    networks:
      - prometheus_external
      - prometheus_internal
    extra_hosts:
      # Allows Prometheus to scrape the "Agent" on this same node
      - "host.docker.internal:host-gateway"
    labels:
      - "traefik.enable=true"
      - "traefik.docker.network=prometheus_external"
      - "traefik.http.routers.prom.rule=Host(`${PROM_HOST_NAME}.${TRAEFIK_DNS_SUFFIX}`)"
      - "traefik.http.routers.prom.tls=true"
      - "traefik.http.routers.prom.tls.certresolver=dns_resolver"
      - "traefik.http.services.prom.loadbalancer.server.port=9090"

networks:
  prometheus_internal:
    driver: bridge
  prometheus_external:
    external: true