"use client"; import { DashboardLayout } from "@/components/dashboard/DashboardLayout"; import { Progress } from "@/components/ui/progress"; import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; import { type ChartConfig } from "@/components/ui/chart"; import GradientAreaChart from "@/components/GradientAreaChart"; import { getMetrics } from "@/core/client/metrics"; import { useEffect, useState } from "react"; const containerMetrics = [ { name: "api-gateway-1", cpu: 45, memory: 62, network: "12.4 MB/s" }, { name: "api-gateway-2", cpu: 52, memory: 58, network: "10.2 MB/s" }, { name: "api-gateway-3", cpu: 38, memory: 55, network: "8.8 MB/s" }, { name: "auth-service-1", cpu: 28, memory: 45, network: "3.2 MB/s" }, { name: "auth-service-2", cpu: 32, memory: 48, network: "2.8 MB/s" }, { name: "postgres-db-1", cpu: 65, memory: 78, network: "8.1 MB/s" }, { name: "redis-cache-1", cpu: 12, memory: 34, network: "1.8 MB/s" }, { name: "worker-queue-1", cpu: 55, memory: 48, network: "5.6 MB/s" }, ]; const cpuChartConfig = { cpu: { label: "CPU Usage", color: "var(--chart-1)" }, } satisfies ChartConfig; const memoryChartConfig = { memory: { label: "RAM Usage", color: "var(--chart-3)" }, } satisfies ChartConfig; const networkChartConfig = { in: { label: "Inbound", color: "var(--chart-2)" }, out: { label: "Outbound", color: "var(--chart-4)" }, } satisfies ChartConfig; export default function MonitoringPage() { const [data, setData] = useState< { time: string; cpu: number; memory: number; in: number; out: number; }[] >([]); useEffect(() => { async function fetchMetrics() { setData(await getMetrics()); } fetchMetrics(); const i = setInterval(fetchMetrics, 30000); return () => clearInterval(i); }, []); return ( {/* Summary Stats */}
Cluster CPU
68%
Cluster Memory
71%
Network In
38 MB/s
↑ 12% from avg
Network Out
28 MB/s
↓ 5% from avg
{/* CPU & Memory Charts */}
{/* Container Metrics */} Container Metrics
{containerMetrics.map((container) => (
{container.name}
CPU {container.cpu}%
Memory {container.memory}%
Network {container.network}
))}
); }