feat: add CPU usage to agent response and compact cards
Backend: - Add cpuUsage field to AgentInstanceResponse (-1 if unavailable) - Add queryAgentCpuUsage() to AgentRegistrationController — queries avg CPU per instance from agent_metrics over last 2 minutes - Wire CPU into agent list response via withCpuUsage() Frontend: - Add cpuUsage to schema.d.ts - Compute maxCpu per AppGroup (max across all instances) - Show "X% cpu" on compact cards when available (hidden when -1) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2
ui/src/api/schema.d.ts
vendored
2
ui/src/api/schema.d.ts
vendored
@@ -2065,6 +2065,8 @@ export interface components {
|
||||
totalRoutes: number;
|
||||
/** Format: int64 */
|
||||
uptimeSeconds: number;
|
||||
/** Format: double */
|
||||
cpuUsage: number;
|
||||
};
|
||||
SseEmitter: {
|
||||
/** Format: int64 */
|
||||
|
||||
@@ -321,6 +321,11 @@
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.compactCardCpu {
|
||||
font-family: var(--font-mono);
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.compactCardHeartbeat {
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
@@ -52,6 +52,7 @@ interface AppGroup {
|
||||
totalTps: number;
|
||||
totalActiveRoutes: number;
|
||||
totalRoutes: number;
|
||||
maxCpu: number;
|
||||
}
|
||||
|
||||
function groupByApp(agentList: AgentInstance[]): AppGroup[] {
|
||||
@@ -71,6 +72,7 @@ function groupByApp(agentList: AgentInstance[]): AppGroup[] {
|
||||
totalTps: instances.reduce((s, i) => s + (i.tps ?? 0), 0),
|
||||
totalActiveRoutes: instances.reduce((s, i) => s + (i.activeRoutes ?? 0), 0),
|
||||
totalRoutes: instances.reduce((s, i) => s + (i.totalRoutes ?? 0), 0),
|
||||
maxCpu: Math.max(...instances.map((i) => (i as AgentInstance & { cpuUsage?: number }).cpuUsage ?? -1)),
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -141,6 +143,11 @@ function CompactAppCard({ group, onExpand, onNavigate }: { group: AppGroup; onEx
|
||||
<span className={styles.compactCardTps}>
|
||||
{group.totalTps.toFixed(1)} tps
|
||||
</span>
|
||||
{group.maxCpu >= 0 && (
|
||||
<span className={styles.compactCardCpu}>
|
||||
{(group.maxCpu * 100).toFixed(0)}% cpu
|
||||
</span>
|
||||
)}
|
||||
<span className={isHealthy ? styles.compactCardHeartbeat : styles.compactCardHeartbeatWarn}>
|
||||
{heartbeat ? timeAgo(heartbeat) : '\u2014'}
|
||||
</span>
|
||||
|
||||
Reference in New Issue
Block a user