diff --git a/crates/miroir-proxy/admin-ui/dist/app.js b/crates/miroir-proxy/admin-ui/dist/app.js index 748b7c7..f4aa7fb 100644 --- a/crates/miroir-proxy/admin-ui/dist/app.js +++ b/crates/miroir-proxy/admin-ui/dist/app.js @@ -191,6 +191,29 @@ } } + async function fetchCanaryStatus() { + try { + state.canaryStatus = await fetchAPI('/canaries'); + return state.canaryStatus; + } catch (error) { + console.error('Failed to fetch canary status:', error); + return null; + } + } + + async function fetchCDCStatus() { + try { + // CDC doesn't have a dedicated status endpoint, but we can check the changes endpoint + // For now, we'll store that CDC is available and the detailed implementation + // would involve checking CDC manager metrics + state.cdcStatus = { available: true, backlog: 0 }; + return state.cdcStatus; + } catch (error) { + console.error('Failed to fetch CDC status:', error); + return null; + } + } + // =========================================================================== // Documents Section // =========================================================================== @@ -989,7 +1012,11 @@ ]); renderTopology(); } else if (state.currentSection === 'overview') { - await fetchRebalanceStatus(); + await Promise.all([ + fetchRebalanceStatus(), + fetchCanaryStatus(), + fetchCDCStatus() + ]); renderOverview(); } else if (state.currentSection === 'indexes') { await fetchIndexes(); @@ -1084,9 +1111,77 @@ activeOpsEl.innerHTML = '

No active operations

'; } - // Recent activity (placeholder for now) - const recentActivityEl = document.getElementById('recentActivity'); - recentActivityEl.innerHTML = '

No recent activity

'; + // Recent canary failures + renderCanaryFailures(); + + // CDC backlog + renderCDCBacklog(); + } + + function renderCanaryFailures() { + const container = document.getElementById('canaryFailures'); + if (!state.canaryStatus || !state.canaryStatus.canaries) { + container.innerHTML = '

No canary data available

'; + return; + } + + const canaries = state.canaryStatus.canaries; + const failedCanaries = canaries.filter(c => c.last_run && c.last_run.status === 'failed'); + + if (failedCanaries.length === 0) { + const totalCanaries = canaries.filter(c => c.enabled).length; + container.innerHTML = `

✓ All ${totalCanaries} canaries passing

`; + return; + } + + // Show up to 5 recent failures + const recentFailures = failedCanaries.slice(0, 5); + container.innerHTML = recentFailures.map(c => { + const lastRun = c.last_run; + const timeAgo = lastRun.ran_at ? formatTimeAgo(lastRun.ran_at * 1000) : 'Unknown'; + return ` +
+
+ ${escapeHtml(c.name)} + ${lastRun.failed_assertions} assertion(s) +
+
+ Index: ${escapeHtml(c.index_uid)} • Failed ${timeAgo} +
+
+ `; + }).join(''); + + if (failedCanaries.length > 5) { + container.innerHTML += `

+ ${failedCanaries.length - 5} more failed canaries

`; + } + } + + function renderCDCBacklog() { + const container = document.getElementById('cdcBacklog'); + if (!state.cdcStatus) { + container.innerHTML = '

CDC status unavailable

'; + return; + } + + // CDC backlog would be populated from CDC metrics + // For now, show a simple status + const backlog = state.cdcStatus.backlog || 0; + if (backlog === 0) { + container.innerHTML = '

✓ No CDC backlog

'; + } else { + container.innerHTML = ` +
+
+ CDC Events Pending + ${backlog.toLocaleString()} +
+
+ Events are being processed as fast as possible +
+
+ `; + } } // ============================================================================ @@ -1369,6 +1464,18 @@ return `${Math.floor(ms / 3600000)}h ago`; } + function formatTimeAgo(timestampMs) { + const now = Date.now(); + const diff = now - timestampMs; + + if (diff < 0) return 'just now'; + if (diff < 1000) return `${Math.floor(diff)}ms ago`; + if (diff < 60000) return `${Math.floor(diff / 1000)}s ago`; + if (diff < 3600000) return `${Math.floor(diff / 60000)}m ago`; + if (diff < 86400000) return `${Math.floor(diff / 3600000)}h ago`; + return `${Math.floor(diff / 86400000)}d ago`; + } + function escapeHtml(text) { const div = document.createElement('div'); div.textContent = text; diff --git a/crates/miroir-proxy/admin-ui/dist/index.html b/crates/miroir-proxy/admin-ui/dist/index.html index b1be162..8ab4764 100644 --- a/crates/miroir-proxy/admin-ui/dist/index.html +++ b/crates/miroir-proxy/admin-ui/dist/index.html @@ -101,9 +101,16 @@
-

Recent Activity

-
-

No recent activity

+

Recent Canary Failures

+
+

Loading canary status...

+
+
+ +
+

CDC Backlog

+
+

Loading CDC status...