#!/bin/bash # S3 Log Monitor Demo - Usage examples for foxhunt-deploy monitor command set -e echo "=== S3 Log Monitor Demo ===" echo "" # Check prerequisites if [[ -z "$AWS_ACCESS_KEY_ID" ]]; then echo "ERROR: AWS_ACCESS_KEY_ID not set" echo "Please set RunPod S3 credentials:" echo " export AWS_ACCESS_KEY_ID='your_key'" echo " export AWS_SECRET_ACCESS_KEY='your_secret'" exit 1 fi # Example pod ID (replace with your actual pod ID) POD_ID="${1:-dy2bn5ninzaxma}" echo "Pod ID: $POD_ID" echo "" # Function to run example run_example() { local description="$1" local command="$2" echo "────────────────────────────────────────────────────────────────" echo "Example: $description" echo "Command: $command" echo "────────────────────────────────────────────────────────────────" echo "" echo "Press Enter to run (or Ctrl+C to skip)..." read -r eval "$command" echo "" } # Example 1: List available log files run_example \ "List all log files for the pod" \ "foxhunt-deploy monitor $POD_ID --list" # Example 2: Show last 20 lines run_example \ "Show last 20 lines of logs" \ "foxhunt-deploy monitor $POD_ID --tail 20" # Example 3: Show last 50 lines run_example \ "Show last 50 lines of logs" \ "foxhunt-deploy monitor $POD_ID --tail 50" # Example 4: Follow logs in real-time echo "────────────────────────────────────────────────────────────────" echo "Example: Follow logs in real-time (Ctrl+C to exit)" echo "Command: foxhunt-deploy monitor $POD_ID --follow" echo "────────────────────────────────────────────────────────────────" echo "" echo "This will stream logs continuously. Press Ctrl+C to stop." echo "Press Enter to start..." read -r foxhunt-deploy monitor "$POD_ID" --follow # Example 5: Follow with initial tail echo "" echo "────────────────────────────────────────────────────────────────" echo "Example: Follow logs with initial 10 lines" echo "Command: foxhunt-deploy monitor $POD_ID --follow --tail 10" echo "────────────────────────────────────────────────────────────────" echo "" echo "Press Enter to start (Ctrl+C to stop)..." read -r foxhunt-deploy monitor "$POD_ID" --follow --tail 10 # Example 6: Filter by pattern echo "" echo "────────────────────────────────────────────────────────────────" echo "Example: Filter logs for 'epoch' or 'loss'" echo "Command: foxhunt-deploy monitor $POD_ID --follow --filter 'epoch|loss'" echo "────────────────────────────────────────────────────────────────" echo "" echo "Press Enter to start (Ctrl+C to stop)..." read -r foxhunt-deploy monitor "$POD_ID" --follow --filter "epoch|loss" # Example 7: Filter for errors only echo "" echo "────────────────────────────────────────────────────────────────" echo "Example: Show only errors and warnings" echo "Command: foxhunt-deploy monitor $POD_ID --follow --filter 'ERROR|WARN'" echo "────────────────────────────────────────────────────────────────" echo "" echo "Press Enter to start (Ctrl+C to stop)..." read -r foxhunt-deploy monitor "$POD_ID" --follow --filter "ERROR|WARN" echo "" echo "=== Demo Complete ===" echo "" echo "Common usage patterns:" echo "" echo "1. Quick check: Show last 20 lines" echo " foxhunt-deploy monitor $POD_ID --tail 20" echo "" echo "2. Monitor training: Follow in real-time" echo " foxhunt-deploy monitor $POD_ID --follow" echo "" echo "3. Debug errors: Filter for problems" echo " foxhunt-deploy monitor $POD_ID --follow --filter 'ERROR|WARN|CRITICAL'" echo "" echo "4. Track metrics: Filter for training stats" echo " foxhunt-deploy monitor $POD_ID --follow --filter 'epoch.*loss|accuracy'" echo "" echo "5. List logs: See all available log files" echo " foxhunt-deploy monitor $POD_ID --list" echo ""