@echo off
echo ============================================================
echo    RE Workflow Monitoring Stack - Startup Script
echo ============================================================
echo.

:: Check if Docker is running
docker info >nul 2>&1
if errorlevel 1 (
    echo [ERROR] Docker is not running. Please start Docker Desktop first.
    pause
    exit /b 1
)

echo [INFO] Docker is running.
echo.

:: Navigate to monitoring directory
cd /d "%~dp0"
echo [INFO] Working directory: %cd%
echo.

:: Start monitoring stack
echo [INFO] Starting monitoring stack...
echo.
docker-compose -f docker-compose.monitoring.yml up -d

if errorlevel 1 (
    echo.
    echo [ERROR] Failed to start monitoring stack.
    pause
    exit /b 1
)

echo.
echo ============================================================
echo    Monitoring Stack Started Successfully!
echo ============================================================
echo.
echo    Services:
echo    ---------------------------------------------------------
echo    Grafana:       http://localhost:3001
echo                   Username: admin
echo                   Password: REWorkflow@2024
echo.
echo    Prometheus:    http://localhost:9090
echo.
echo    Loki:          http://localhost:3100
echo.
echo    Alertmanager:  http://localhost:9093
echo    ---------------------------------------------------------
echo.
echo    Next Steps:
echo    1. Add LOKI_HOST=http://localhost:3100 to your .env file
echo    2. Restart your backend application
echo    3. Open Grafana at http://localhost:3001
echo    4. Navigate to Dashboards ^> RE Workflow
echo.
echo ============================================================

:: Show container status
echo.
echo [INFO] Container Status:
docker ps --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}"
echo.

pause

