docs: add Monitor Dashboard Improvements recommendation for Studio team
- Document new/enhanced API endpoints (worker_status, data-consistency) - UI improvement recommendations (empty state, worker health, consistency check) - Priority matrix and implementation guide - Files to modify list for Studio team
This commit is contained in:
@@ -0,0 +1,238 @@
|
||||
# Monitor Dashboard Improvements - API & UI Recommendations
|
||||
|
||||
**Date**: 2026-10-18
|
||||
**From**: Core Team
|
||||
**To**: Studio Team
|
||||
**Priority**: Medium
|
||||
|
||||
---
|
||||
|
||||
## Overview
|
||||
|
||||
The Core team has enhanced the Monitor API endpoints. This document provides recommendations for updating the Monitor dashboard UI to utilize the new API capabilities and improve user experience.
|
||||
|
||||
---
|
||||
|
||||
## New/Updated API Endpoints
|
||||
|
||||
### 1. GET `/api/v1/monitor/worker_status` (Enhanced)
|
||||
|
||||
**New fields added**:
|
||||
|
||||
| Field | Type | Description |
|
||||
|-------|------|-------------|
|
||||
| `worker_pid` | `u32` | Worker process PID (from `pgrep`) |
|
||||
| `uptime_secs` | `u64` | System uptime (approximation) |
|
||||
| `last_poll_at` | `Option<String>` | Last job activity timestamp |
|
||||
| `poll_interval_secs` | `u64` | Worker poll interval (default: 5) |
|
||||
| `is_alive` | `bool` | Whether worker process is running |
|
||||
|
||||
**Example Response**:
|
||||
```json
|
||||
{
|
||||
"cpu_percent": 50.0,
|
||||
"gpu_percent": 0.0,
|
||||
"memory_mb": 27526,
|
||||
"memory_percent": 56.0,
|
||||
"active_processors": 0,
|
||||
"max_processors": 6,
|
||||
"processors": [],
|
||||
"worker_pid": 48844,
|
||||
"uptime_secs": 1792311585,
|
||||
"last_poll_at": null,
|
||||
"poll_interval_secs": 5,
|
||||
"is_alive": true
|
||||
}
|
||||
```
|
||||
|
||||
### 2. GET `/api/v1/file/:file_uuid/data-consistency` (New)
|
||||
|
||||
**Purpose**: Check data consistency across storage layers.
|
||||
|
||||
**Example Response**:
|
||||
```json
|
||||
{
|
||||
"file_uuid": "5a0aca42c06fa425d559b6af0caced12",
|
||||
"tkg_nodes": 123,
|
||||
"trace_profiles": 123,
|
||||
"trace_dirs": 1881,
|
||||
"qdrant_points": 1881,
|
||||
"qdrant_unique_traces": 123,
|
||||
"is_consistent": false,
|
||||
"mismatches": ["tkg_nodes (123) != trace_dirs (1881)"]
|
||||
}
|
||||
```
|
||||
|
||||
### 3. Existing Endpoints (Unchanged)
|
||||
|
||||
| Endpoint | Response |
|
||||
|----------|----------|
|
||||
| `GET /api/v1/monitor/queue_stats` | `{pending, running, completed, failed}` |
|
||||
| `GET /api/v1/monitor/running_jobs` | `{jobs: [...]}` |
|
||||
| `GET /api/v1/health` | `{status, worker_running, ...}` |
|
||||
|
||||
---
|
||||
|
||||
## UI Improvement Recommendations
|
||||
|
||||
### 1. Empty State Handling
|
||||
|
||||
**Current Issue**: When `running_jobs` returns `[]`, the page shows blank content.
|
||||
|
||||
**Recommendation**:
|
||||
```vue
|
||||
<!-- PeopleView.vue or MonitorView.vue -->
|
||||
<div v-if="runningJobs.length === 0" class="empty-state">
|
||||
<div class="icon">📭</div>
|
||||
<h3>No Active Jobs</h3>
|
||||
<p>All jobs are completed. New jobs will appear here when registered.</p>
|
||||
<button @click="refresh">Refresh</button>
|
||||
</div>
|
||||
```
|
||||
|
||||
### 2. Worker Health Indicator
|
||||
|
||||
**New Component**: Add a worker status badge in the header.
|
||||
|
||||
```vue
|
||||
<div class="worker-status" :class="{ alive: worker.is_alive, dead: !worker.is_alive }">
|
||||
<span class="status-dot"></span>
|
||||
<span>Worker {{ worker.is_alive ? 'Running' : 'Offline' }}</span>
|
||||
<span v-if="worker.is_alive" class="pid">PID: {{ worker.worker_pid }}</span>
|
||||
</div>
|
||||
```
|
||||
|
||||
**CSS**:
|
||||
```css
|
||||
.worker-status {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
padding: 4px 12px;
|
||||
border-radius: 16px;
|
||||
font-size: 14px;
|
||||
}
|
||||
.worker-status.alive {
|
||||
background: rgba(34, 197, 94, 0.1);
|
||||
color: #22c55e;
|
||||
}
|
||||
.worker-status.dead {
|
||||
background: rgba(239, 68, 68, 0.1);
|
||||
color: #ef4444;
|
||||
}
|
||||
.status-dot {
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
border-radius: 50%;
|
||||
background: currentColor;
|
||||
}
|
||||
```
|
||||
|
||||
### 3. Recent Completed Jobs Section
|
||||
|
||||
**New Section**: Show last 5 completed jobs.
|
||||
|
||||
```vue
|
||||
<div class="completed-jobs">
|
||||
<h3>Recently Completed</h3>
|
||||
<ul>
|
||||
<li v-for="job in completedJobs.slice(0, 5)" :key="job.uuid">
|
||||
<span class="uuid">{{ job.uuid.slice(0, 12) }}...</span>
|
||||
<span class="status completed">✓ Completed</span>
|
||||
<span class="time">{{ formatTime(job.completed_at) }}</span>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
```
|
||||
|
||||
**API**: Use `GET /api/v1/jobs?page=1&page_size=5&status=completed` (if available) or poll the queue stats for completed count changes.
|
||||
|
||||
### 4. Data Consistency Checker
|
||||
|
||||
**New Feature**: Add a "Check Consistency" button on file detail pages.
|
||||
|
||||
```vue
|
||||
<button @click="checkConsistency(fileUuid)" class="btn-secondary">
|
||||
🔍 Check Data Consistency
|
||||
</button>
|
||||
|
||||
<div v-if="consistencyResult" class="consistency-report" :class="{ error: !consistencyResult.is_consistent }">
|
||||
<h4>Data Consistency Report</h4>
|
||||
<ul>
|
||||
<li>TKG Nodes: {{ consistencyResult.tkg_nodes }}</li>
|
||||
<li>Trace Profiles: {{ consistencyResult.trace_profiles }}</li>
|
||||
<li>Trace Dirs: {{ consistencyResult.trace_dirs }}</li>
|
||||
<li>Qdrant Points: {{ consistencyResult.qdrant_points }}</li>
|
||||
</ul>
|
||||
<div v-if="consistencyResult.mismatches.length > 0" class="errors">
|
||||
<p>Mismatches detected:</p>
|
||||
<ul>
|
||||
<li v-for="m in consistencyResult.mismatches" :key="m">{{ m }}</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
```
|
||||
|
||||
### 5. Zombie Job Cleanup Button
|
||||
|
||||
**New Admin Feature**: Add a button to clean up zombie jobs (Redis keys with no matching files).
|
||||
|
||||
```vue
|
||||
<button v-if="isAdmin" @click="cleanupZombieJobs" class="btn-danger">
|
||||
🧹 Clean Zombie Jobs
|
||||
</button>
|
||||
```
|
||||
|
||||
**Implementation**: Call a new Core API endpoint `POST /api/v1/admin/cleanup-zombie-jobs` (needs to be added to Core).
|
||||
|
||||
---
|
||||
|
||||
## Data Flow Diagram
|
||||
|
||||
```
|
||||
┌─────────────┐ ┌──────────────┐ ┌─────────────┐
|
||||
│ Browser │────▶│ Core API │────▶│ PostgreSQL │
|
||||
│ │◀────│ (port 3002) │◀────│ / Redis │
|
||||
└─────────────┘ └──────────────┘ └─────────────┘
|
||||
│
|
||||
├── GET /api/v1/monitor/queue_stats
|
||||
├── GET /api/v1/monitor/running_jobs
|
||||
├── GET /api/v1/monitor/worker_status (enhanced)
|
||||
└── GET /api/v1/file/:uuid/data-consistency (new)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Priority Matrix
|
||||
|
||||
| Feature | Priority | Effort | Impact |
|
||||
|---------|----------|--------|--------|
|
||||
| Empty state handling | 🔴 High | Low | High |
|
||||
| Worker health indicator | 🟡 Medium | Low | Medium |
|
||||
| Recent completed jobs | 🟡 Medium | Medium | Medium |
|
||||
| Data consistency checker | 🟢 Low | Medium | Low |
|
||||
| Zombie job cleanup | 🟢 Low | High | Low |
|
||||
|
||||
---
|
||||
|
||||
## Files to Modify (Studio)
|
||||
|
||||
| File | Changes |
|
||||
|------|---------|
|
||||
| `src/views/MonitorView.vue` | Add empty state, worker health badge |
|
||||
| `src/components/WorkerStatus.vue` | New component for worker indicator |
|
||||
| `src/components/ConsistencyReport.vue` | New component for data check |
|
||||
| `src/stores/monitor.ts` | Add worker status polling |
|
||||
| `src/api/monitor.ts` | Add new API methods |
|
||||
|
||||
---
|
||||
|
||||
## Next Steps
|
||||
|
||||
1. **Core Team**: Add `POST /api/v1/admin/cleanup-zombie-jobs` endpoint (if needed)
|
||||
2. **Studio Team**: Review and implement UI changes based on priority
|
||||
3. **Both**: Coordinate on API contract changes
|
||||
|
||||
---
|
||||
|
||||
**Contact**: Core Team for API questions, Studio Team for UI implementation.
|
||||
Reference in New Issue
Block a user