diff --git a/src/apps/metrics-systems/components/MetricsDashboard.tsx b/src/apps/metrics-systems/components/MetricsDashboard.tsx index b5edc1a..c19a332 100644 --- a/src/apps/metrics-systems/components/MetricsDashboard.tsx +++ b/src/apps/metrics-systems/components/MetricsDashboard.tsx @@ -48,15 +48,33 @@ interface TimeSeriesResponse { series: TimeSeries[] } +interface ContainerStats { + name: string + cpu_usage_percent: number + cpu_throttled_seconds: number + memory_usage_bytes: number + memory_limit_bytes: number + memory_usage_percent: number + network_rx_bytes_per_sec: number + network_tx_bytes_per_sec: number +} + +interface ContainerMetrics { + timestamp: string + containers: ContainerStats[] +} + interface MetricsDashboardProps { onConnectionStateChange: (status: 'connecting' | 'connected' | 'disconnected' | 'failed') => void - activeTab?: 'system' | 'portrait' - onTabChange?: (tab: 'system' | 'portrait') => void + activeTab?: 'system' | 'containers' | 'portrait' + onTabChange?: (tab: 'system' | 'containers' | 'portrait') => void } const MetricsDashboard = ({ onConnectionStateChange, activeTab = 'system', onTabChange }: MetricsDashboardProps) => { const [systemMetrics, setSystemMetrics] = useState(null) const [systemTimeseries, setSystemTimeseries] = useState(null) + const [containerMetrics, setContainerMetrics] = useState(null) + const [containerTimeseries, setContainerTimeseries] = useState(null) const [portraitTimeseries, setPortraitTimeseries] = useState(null) const [timeRange, setTimeRange] = useState<'30m' | '1d' | '7d'>('1d') const [lastUpdate, setLastUpdate] = useState(null) @@ -96,6 +114,34 @@ const MetricsDashboard = ({ onConnectionStateChange, activeTab = 'system', onTab // Silently handle error - UI will show "no data" state } + // Fetch container metrics + try { + const containerResponse = await fetch(`${apiUrl}/v1/metrics/containers`) + if (containerResponse.ok) { + const text = await containerResponse.text() + if (text.trim()) { + const containerData = JSON.parse(text) + setContainerMetrics(containerData) + } + } + } catch { + // Silently handle error - UI will show "no data" state + } + + // Fetch container timeseries + try { + const containerTimeseriesResponse = await fetch(`${apiUrl}/v1/timeseries/containers/${timeRange}`) + if (containerTimeseriesResponse.ok) { + const text = await containerTimeseriesResponse.text() + if (text.trim()) { + const containerTimeseriesData = JSON.parse(text) + setContainerTimeseries(containerTimeseriesData) + } + } + } catch { + // Silently handle error - UI will show "no data" state + } + // Fetch portrait timeseries try { const portraitTimeseriesResponse = await fetch(`${apiUrl}/v1/timeseries/portrait/${timeRange}`) @@ -414,6 +460,12 @@ const MetricsDashboard = ({ onConnectionStateChange, activeTab = 'system', onTab > System Metrics +