# Phase 1 (Job 893) Monitoring Guide **Status:** Ready to monitor **Job ID:** 00000000-0000-0000-0000-000000000893 **Duration:** 50-90 trading days (autonomous) **Updated:** 2026-08-06 --- ## Prerequisites 1. **SSH Tunnel** (Terminal 1 - Keep Open) ```powershell ssh -L 5432:127.0.0.1:5432 kjh2064@178.104.200.7 ``` 2. **Host Application** (Terminal 2 - Keep Open) ```powershell cd D:\JobRoomz\KArtSell.Aegis # Set environment $env:KARTSELL_POSTGRES = "Host=localhost;Port=5432;Database=kartsell;Username=kartsell;Password=kartsell" $env:KRX_OPENAPI = "" # from Gitea Secrets $env:OPENDART_API = "" $env:KIS_API_KEY = "" # Start in DEVELOPMENT mode (critical for testing) dotnet run --project src/KArtSell.Host --configuration Debug --no-build ``` Expected output: ``` info: Microsoft.Hosting.Lifetime[14] Now listening on: http://127.0.0.1:5002 ``` 3. **Monitoring Dashboard** (Terminal 3 - Monitor) ```powershell # Option A: Hangfire Dashboard (Real-time UI) Start-Process "http://localhost:5002/hangfire" # Option B: Database queries (Command line) # See below ``` --- ## Monitoring Methods ### Method 1: Hangfire Dashboard (Recommended) **URL:** `http://localhost:5002/hangfire` **What to watch:** - **Queues:** `q-research` queue depth - **Processing:** Active job (should be Job 893) - **Jobs:** Completed/Failed count - **Scheduled:** Any pending tasks **Metrics:** - Current queue depth - Processing rate (rows/second) - Average job duration - Error count & last error ### Method 2: Database Queries **Check Job Status:** ```bash psql -h localhost -U kartsell -d kartsell < 24 hours → Check logs - Error rate > 5% → Investigate data quality - Memory usage > 80% → Consider restart **Safe to ignore:** - Progress rate varies (weekend vs weekday) - Occasional transient errors (network glitches) - Queue depth spikes (normal batch processing) --- ## Monitoring Commands Reference ```powershell # Check Host health curl http://localhost:5002/health # View Hangfire in browser Start-Process "http://localhost:5002/hangfire" # Database status (one-liner) psql -h localhost -U kartsell -d kartsell -c "SELECT status, progress_percent, rows_processed FROM model_operations.shadow_runs WHERE job_id = '00000000-0000-0000-0000-000000000893'" # Stop Host gracefully # Press Ctrl+C in Host terminal # View all Job 893 events psql -h localhost -U kartsell -d kartsell -c "SELECT event_type, created_at, details FROM audit.job_events WHERE job_id = '00000000-0000-0000-0000-000000000893' ORDER BY created_at DESC LIMIT 20" ``` --- ## Success Criteria ✅ **Job 893 Monitoring Active** when: 1. SSH tunnel is open 2. Host is listening on 127.0.0.1:5002 3. Database returns `status = 'Running'` and `progress_percent > 0` 4. Hangfire dashboard shows Job 893 in queue or processing --- ## Troubleshooting ### "Host not responding" ```powershell # Check if process is running Get-Process | Where-Object {$_.ProcessName -like "*Host*"} # Restart Host dotnet run --project src/KArtSell.Host --configuration Debug ``` ### "SSH tunnel failed" ```bash # Check SSH key permissions ls -la ~/.ssh/id_rsa # Should be 600 # Test SSH connection ssh kjh2064@178.104.200.7 -v ``` ### "Database connection refused" ```powershell # Check port forwarding Test-NetConnection -ComputerName localhost -Port 5432 # Restart SSH tunnel in Terminal 1 ssh -L 5432:127.0.0.1:5432 kjh2064@178.104.200.7 ``` ### "No rows in shadow_runs table" - Job 893 may not have started yet - Check Hangfire queue: http://localhost:5002/hangfire - Verify Gate 3 API was called (see PHASE_1_STARTUP_GUIDE.md) --- ## 3-Terminal Setup (Recommended) ``` Terminal 1 (SSH) Terminal 2 (Host) Terminal 3 (Monitor) │ │ │ ├─ ssh -L 5432 ... ├─ dotnet run Host ├─ Hangfire dashboard │ (Keep open) │ (Keep open) │ OR │ │ ├─ PowerShell loop │ │ └─ psql queries ``` Each terminal: - Separate window/tab - Keep open for entire Phase 1 duration - Log output for troubleshooting - Do NOT close during run --- ## Log Files - **Host logs:** `logs/host-*.log` (check for errors) - **Job logs:** `model_operations.job_logs` table (database) - **Audit trail:** `audit.job_events` table (database) - **Hangfire logs:** Embedded in Host logs --- ## Phase 1 Completion When `status = 'Completed'`: 1. ✅ Check final `progress_percent = 100` 2. ✅ Verify `last_error IS NULL` 3. ✅ Record `rows_processed` (expected: 20M+) 4. ✅ Save completion timestamp 5. ✅ Proceed to Production Deployment (DEPLOY_PRODUCTION_NOW.ps1) **Estimated completion:** November 2026 (50-90 trading days from start) --- **Document Version:** 1.0 **Last Updated:** 2026-08-06 **AGENTS.md Compliance:** v16.0 ✅