# docker-compose.observability.yml -- Observability stack (Prometheus + Grafana)
# Usage: docker compose -f docker-compose.yml -f docker-compose.observability.yml up -d
# Or with dev services: docker compose -f docker-compose.yml -f docker-compose.override.yml -f docker-compose.observability.yml up -d

services:
  prometheus:
    image: prom/prometheus:latest
    container_name: tod_prometheus
    ports:
      - "9090:9090"
    volumes:
      - ./infrastructure/observability/prometheus.yml:/etc/prometheus/prometheus.yml:ro
      - ./docker-data/prometheus:/prometheus
    command:
      - '--config.file=/etc/prometheus/prometheus.yml'
      - '--storage.tsdb.path=/prometheus'
      - '--storage.tsdb.retention.time=15d'
      - '--web.console.libraries=/usr/share/prometheus/console_libraries'
      - '--web.console.templates=/usr/share/prometheus/consoles'
    deploy:
      resources:
        limits:
          memory: 256M
    networks:
      - tod

  grafana:
    image: grafana/grafana:latest
    container_name: tod_grafana
    ports:
      - "3001:3000"
    volumes:
      - ./infrastructure/observability/grafana/provisioning:/etc/grafana/provisioning:ro
      - ./infrastructure/observability/grafana/dashboards:/var/lib/grafana/dashboards:ro
      - ./docker-data/grafana:/var/lib/grafana
    environment:
      GF_SECURITY_ADMIN_USER: admin
      GF_SECURITY_ADMIN_PASSWORD: admin
      GF_AUTH_ANONYMOUS_ENABLED: "true"
      GF_AUTH_ANONYMOUS_ORG_ROLE: Viewer
      GF_DASHBOARDS_DEFAULT_HOME_DASHBOARD_PATH: /var/lib/grafana/dashboards/api-overview.json
    deploy:
      resources:
        limits:
          memory: 128M
    depends_on:
      - prometheus
    networks:
      - tod
