@@ -61,6 +61,10 @@ type DetailPanel struct {
6161 // Sparkline row component for metrics visualization
6262 sparklineRow * ui.SparklineRow
6363
64+ // Adaptive scaling for Net/Disk sparklines
65+ peakNetRate float64
66+ peakDiskRate float64
67+
6468 // Callbacks
6569 onNodeNavigate NodeNavigationCallback
6670 onContainerSelected ContainerSelectedCallback
@@ -324,6 +328,8 @@ func (p *DetailPanel) DrawBody(data interface{}) {
324328 }
325329 if newPodKey != p .currentPodKey {
326330 p .resetSparklines ()
331+ p .peakNetRate = 0 // Reset adaptive scaling peaks
332+ p .peakDiskRate = 0
327333 p .currentPodKey = newPodKey
328334
329335 // Populate sparklines from history if available
@@ -460,8 +466,52 @@ func (p *DetailPanel) drawSparklines() {
460466
461467 // Update network/disk sparklines in prometheus mode
462468 if prometheusMode {
463- p .sparklineRow .UpdateNET (0.01 , " NET [gray]↓n/a ↑n/a[-] " )
464- p .sparklineRow .UpdateDisk (0.01 , " DISK [gray]R:n/a W:n/a[-] " )
469+ // Network sparkline - Note: Pod-level network metrics are NOT available in
470+ // containerd-based Kubernetes. cAdvisor only exports network at node level.
471+ // Show "n/a" when no data is available.
472+ combinedNetRate := p .data .NetworkRxRate + p .data .NetworkTxRate
473+ if combinedNetRate > 0 || p .peakNetRate > 0 {
474+ // We have or had network data - show with adaptive scaling
475+ netTitle := fmt .Sprintf (" Net ↓%s ↑%s " ,
476+ ui .FormatBytesRate (p .data .NetworkRxRate ),
477+ ui .FormatBytesRate (p .data .NetworkTxRate ))
478+
479+ if combinedNetRate > p .peakNetRate {
480+ p .peakNetRate = combinedNetRate
481+ }
482+ effectiveNetMax := p .peakNetRate
483+ if effectiveNetMax < 512 * 1024 {
484+ effectiveNetMax = 512 * 1024
485+ }
486+ netNormalized := combinedNetRate / effectiveNetMax
487+ if netNormalized > 1 {
488+ netNormalized = 1
489+ }
490+ p .sparklineRow .UpdateNET (netNormalized , netTitle )
491+ } else {
492+ // No pod-level network metrics available (containerd limitation)
493+ p .sparklineRow .UpdateNET (0 , " Net [gray](unavailable)[-] " )
494+ }
495+
496+ // Disk sparkline with adaptive scaling
497+ diskTitle := fmt .Sprintf (" Disk R:%s W:%s " ,
498+ ui .FormatBytesRate (p .data .DiskReadRate ),
499+ ui .FormatBytesRate (p .data .DiskWriteRate ))
500+ combinedDiskRate := p .data .DiskReadRate + p .data .DiskWriteRate
501+
502+ // Adaptive scaling: track peak, use minimum 512 KB/s baseline
503+ if combinedDiskRate > p .peakDiskRate {
504+ p .peakDiskRate = combinedDiskRate
505+ }
506+ effectiveDiskMax := p .peakDiskRate
507+ if effectiveDiskMax < 512 * 1024 { // Min 512 KB/s baseline
508+ effectiveDiskMax = 512 * 1024
509+ }
510+ diskNormalized := combinedDiskRate / effectiveDiskMax
511+ if diskNormalized > 1 {
512+ diskNormalized = 1
513+ }
514+ p .sparklineRow .UpdateDisk (diskNormalized , diskTitle )
465515 }
466516}
467517
0 commit comments