#!/bin/bash
# EN: Start observability stack
# VI: Khởi động observability stack

set -e

# Source OS helper
source "$(dirname "$0")/../utils/os-helper.sh"

echo "🚀 Starting Observability Stack..."

# Check if network exists, create if not
if ! docker network ls | grep -q "microservices-network"; then
    echo "Creating network 'microservices-network'..."
    docker network create microservices-network
fi

# Resolve project root (assuming script is in scripts/observability)
PROJECT_ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
cd "$PROJECT_ROOT/infra/observability"

run_compose up -d

echo ""
echo "✅ Observability stack started!"
echo "---------------------------------------------------"
echo "📊 Grafana:    http://localhost:3001 (admin/admin)"
echo "📈 Prometheus: http://localhost:9090"
echo "🪵 Loki:       http://localhost:3100"
echo "---------------------------------------------------"
