Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
Fix canonical workload summary hover ids
rcourtman96129265fe16
diff --git a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md b/docs/release-control/v6/internal/subsystems/agent-lifecycle.mdindex dd3ee98061..40043acf6e 100644--- a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md+++ b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md@@ -591,6 +591,10 @@ That same shared router boundary must treat infrastructure summary chartnormalization as summary-only presentation transport: long-range chart bucketshaping may improve operator-facing summary readability, but it must not bereused as lifecycle freshness, heartbeat, or enrollment-state authority.+That same shared chart boundary may resolve provider-backed workload history+through unified metrics targets, but emitted workload IDs must stay on the+canonical `/workloads` row contract so lifecycle settings, reporting, and+handoff surfaces never depend on provider-native metric keys.That same lifecycle-owned settings slice now also owns the shared VMwaresummary and handoff framing. `InfrastructurePlatformConnectionsSummaryCard.tsx`,`InfrastructureReportingPanel.tsx`, `useInfrastructureSettingsState.ts`, anddiff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.mdindex 9b9afb2379..961d126cc2 100644--- a/docs/release-control/v6/internal/subsystems/api-contracts.md+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md@@ -178,6 +178,7 @@ Own canonical runtime payload shapes between backend and frontend.25. Keep chart timestamp precision canonical on that same shared API surface: when `internal/api/router.go` serializes monitoring history into infrastructure or workload chart payloads, it must preserve canonical millisecond timestamps from the shared monitoring timeline instead of rounding through whole-second conversion, so seeded mock history and live appends collapse onto one operator-visible timeline instead of appearing as duplicated tail samples.26. Keep storage chart identity canonical on that same shared API surface: the shared storage charts endpoint must key pool and physical-disk series by the resolved unified-resource `MetricsTarget.ResourceID`, not by canonical resource IDs or page-local aliases, so storage rows, focused summary cards, sticky summary shells, and detail charts all address the same history series in live and mock mode.27. Keep synthetic summary-chart fallback identity canonical on that same shared API surface: when `internal/api/router.go` has to synthesize mock summary history for infrastructure, workloads, or storage cards, it must derive the fallback from canonical `resourceType`, `resourceID`, and `metricType` ownership instead of raw min/max seed-prefix helpers, so range changes and runtime mock updates stay on one governed timeline.+28. Keep workload-chart response identity canonical on that same shared API surface: `internal/api/router.go`, `internal/api/contract_test.go`, and workload summary consumers must emit provider-backed VM and system-container series under the same canonical workload IDs that workloads page rows use, while resolving history through the unified `MetricsTarget.ResourceID`, so hover and focus selection do not fall off for provider-backed rows.## Forbidden Paths@@ -1359,6 +1360,12 @@ continuity semantics: when `/api/auto-register` receives the samecanonical node name together with the deterministic Pulse-managed token ID forthat node, it must update the existing PVE or PBS entry in place even if thehost IP has changed, rather than duplicating the node under a second endpoint.+That same `/api/auto-register` payload contract must now also accept ordered+`candidateHosts` from runtime-side Proxmox callers and treat `host` as the+preferred candidate, not an untouchable answer. The backend must normalize the+candidate list, ignore invalid alternates, and persist the first candidate it+can actually reach for TLS fingerprint capture from Pulse's own network view so+registration payloads do not lock in an endpoint the server cannot later poll.The unified-agent install endpoints now also carry an exact-release fallbackcontract: when `/install.sh` or `/install.ps1` cannot be served locally, thebackend must proxy the install script asset from the exact GitHub release thatdiff --git a/docs/release-control/v6/internal/subsystems/monitoring.md b/docs/release-control/v6/internal/subsystems/monitoring.mdindex 42fcae093e..d3ed22fc88 100644--- a/docs/release-control/v6/internal/subsystems/monitoring.md+++ b/docs/release-control/v6/internal/subsystems/monitoring.md@@ -150,6 +150,12 @@ through the resolved unified-resource metrics target, so seeded history,runtime writes, storage summary hover selection, and detail charts all extendone series instead of splitting between canonical resource IDs andsource-native metric IDs.+That same chart boundary also owns provider-backed workload bridging.+Workload-chart consumers may query VM and system-container history through the+resolved unified-resource metrics target, but the emitted series identity must+stay on the canonical workload row ID, so VMware-backed workloads participate+in summary hover and focus without leaking provider-native metric IDs into the+UI contract.That same summary owner also owns VMware partial-success classification.Optional VI JSON or Automation enrichment reads that fail after basehost/VM/datastore inventory succeeds must not collapse the whole poll into adiff --git a/docs/release-control/v6/internal/subsystems/performance-and-scalability.md b/docs/release-control/v6/internal/subsystems/performance-and-scalability.mdindex 856a94d482..1aa6d9e3a6 100644--- a/docs/release-control/v6/internal/subsystems/performance-and-scalability.md+++ b/docs/release-control/v6/internal/subsystems/performance-and-scalability.md@@ -305,6 +305,11 @@ Docker-native runtime IDs stay in a separate action-only field for Dockercontrols like image updates. Performance work must not collapse API-backedplatforms back onto runtime-native container IDs or derive fake node scopesfrom typed canonical resource IDs.+That same summary hot path must also keep workload hover identity canonical+across provider-backed history. Row hover and focus plus top-card isolation on+`/workloads` must resolve against the same canonical workload ID even when the+backing history is stored under a provider metrics target, so provider-backed+VM rows do not silently drop out of summary emphasis.The shared infrastructure table hot path now also treats operator-facingresource identity as a protected boundary: sorting, searching, summary-seriesmatching, and row titles on the infrastructure page must use the canonicaldiff --git a/docs/release-control/v6/internal/subsystems/storage-recovery.md b/docs/release-control/v6/internal/subsystems/storage-recovery.mdindex 2014800554..4630e4fde7 100644--- a/docs/release-control/v6/internal/subsystems/storage-recovery.md+++ b/docs/release-control/v6/internal/subsystems/storage-recovery.md@@ -169,6 +169,11 @@ querying, and the operator-facing storage health presentation layer.chart highlighting so pool-only cards demote cleanly during disk focus anddisk-temperature cards demote cleanly during pool focus, instead ofleaving stale row-local IDs or storage-local hover branches on the page.+14. Keep cross-surface workload handoffs on canonical IDs too. Shared workload+ chart transport may look up provider-backed VM history through unified+ metrics targets, but infrastructure/workloads/storage/recovery navigation+ and focus handoffs must stay on canonical workload IDs instead of+ provider-native metric keys.## Current Statediff --git a/docs/release-control/v6/internal/subsystems/unified-resources.md b/docs/release-control/v6/internal/subsystems/unified-resources.mdindex 4a7d280924..090f5e1df9 100644--- a/docs/release-control/v6/internal/subsystems/unified-resources.md+++ b/docs/release-control/v6/internal/subsystems/unified-resources.md@@ -990,6 +990,12 @@ discovery, while Docker-native action fields such as `containerId` stayseparate and are only consumed by Docker-specific controls. API-backedplatforms such as TrueNAS must not regress that path back to runtime-nativecontainer ids just because they expose Docker-compatible runtime metadata.+That same workload-state boundary also owns summary-chart identity for+provider-backed workloads. Unified-resource VM and system-container views may+surface `MetricsTarget` only as the history lookup target, while workload+chart transport and hover/focus selection must keep using the canonical+workload row ID so provider-backed workloads such as VMware VMs stay aligned+with `/workloads` rows and summary cards.The drawer's discovery mapper also reuses that helper for pod fallback agentIDs, so the resource-detail path and the dashboard path stay aligned on thesame cluster-name source of truth.diff --git a/internal/api/contract_test.go b/internal/api/contract_test.goindex 87cbcac8de..515078eabc 100644--- a/internal/api/contract_test.go+++ b/internal/api/contract_test.go@@ -568,6 +568,102 @@ func TestContract_WorkloadChartsCapLongRangeMixedCadenceByTime(t *testing.T) {}}+func TestContract_WorkloadChartsUseCanonicalWorkloadIDsForProviderBackedVMs(t *testing.T) {+ monitor, state, history := newTestMonitor(t)+ now := time.Date(2026, time.April, 1, 12, 0, 0, 0, time.UTC)+ metricID := "vc-1:vm:vm-201"++ history.AddGuestMetric(metricID, "cpu", 51, now.Add(-10*time.Minute))+ history.AddGuestMetric(metricID, "memory", 64, now.Add(-5*time.Minute))+ history.AddGuestMetric(metricID, "disk", 43, now.Add(-3*time.Minute))+ history.AddGuestMetric(metricID, "netin", 1200, now.Add(-2*time.Minute))+ history.AddGuestMetric(metricID, "netout", 800, now.Add(-2*time.Minute))++ adapter := unifiedresources.NewMonitorAdapter(nil)+ adapter.PopulateSnapshotAndSupplemental(state.GetSnapshot(), map[unifiedresources.DataSource][]unifiedresources.IngestRecord{+ unifiedresources.SourceVMware: {+ {+ SourceID: metricID,+ Resource: unifiedresources.Resource{+ ID: "vm-vmware-contract",+ Type: unifiedresources.ResourceTypeVM,+ Name: "warehouse-api-01",+ Status: unifiedresources.StatusOnline,+ LastSeen: now,+ MetricsTarget: &unifiedresources.MetricsTarget{+ ResourceType: "vm",+ ResourceID: metricID,+ },+ VMware: &unifiedresources.VMwareData{+ ConnectionID: "vc-1",+ EntityType: "vm",+ ManagedObjectID: "vm-201",+ },+ },+ },+ },+ })+ setTestUnexportedField(t, monitor, "resourceStore", monitoring.ResourceStoreInterface(adapter))++ readState := monitor.GetUnifiedReadStateOrSnapshot()+ if readState == nil || len(readState.VMs()) != 1 || readState.VMs()[0] == nil {+ t.Fatalf("expected one provider-backed VM in read state, got %+v", readState)+ }+ resourceID, _, ok := vmChartRequest(readState.VMs()[0])+ if !ok {+ t.Fatal("expected canonical vm chart request")+ }++ router := &Router{monitor: monitor}++ workloadReq := httptest.NewRequest(http.MethodGet, "/api/charts/workloads?range=1h", nil)+ workloadRec := httptest.NewRecorder()+ router.handleWorkloadCharts(workloadRec, workloadReq)++ if workloadRec.Code != http.StatusOK {+ t.Fatalf("expected workload charts 200, got %d: %s", workloadRec.Code, workloadRec.Body.String())+ }++ var workloadDecoded WorkloadChartsResponse+ if err := json.Unmarshal(workloadRec.Body.Bytes(), &workloadDecoded); err != nil {+ t.Fatalf("unmarshal workload charts response: %v", err)+ }+ if _, ok := workloadDecoded.ChartData[resourceID]; !ok {+ t.Fatalf("expected workload charts keyed by canonical workload id %q, got %v", resourceID, workloadDecoded.ChartData)+ }+ if _, ok := workloadDecoded.ChartData[metricID]; ok {+ t.Fatalf("expected provider metrics target %q to stay out of workload chart response keys", metricID)+ }+ if workloadDecoded.GuestTypes[resourceID] != "vm" {+ t.Fatalf("expected vm guest type for %q, got %q", resourceID, workloadDecoded.GuestTypes[resourceID])+ }++ summaryReq := httptest.NewRequest(http.MethodGet, "/api/charts/workloads-summary?range=1h", nil)+ summaryRec := httptest.NewRecorder()+ router.handleWorkloadsSummaryCharts(summaryRec, summaryReq)++ if summaryRec.Code != http.StatusOK {+ t.Fatalf("expected workloads summary 200, got %d: %s", summaryRec.Code, summaryRec.Body.String())+ }++ var summaryDecoded WorkloadsSummaryChartsResponse+ if err := json.Unmarshal(summaryRec.Body.Bytes(), &summaryDecoded); err != nil {+ t.Fatalf("unmarshal workloads summary response: %v", err)+ }+ if summaryDecoded.GuestCounts.Total != 1 || summaryDecoded.GuestCounts.Running != 1 {+ t.Fatalf("expected stable provider-backed guest counts, got %+v", summaryDecoded.GuestCounts)+ }+ if len(summaryDecoded.TopContributors.CPU) == 0 {+ t.Fatal("expected provider-backed cpu top contributor")+ }+ if summaryDecoded.TopContributors.CPU[0].ID != resourceID {+ t.Fatalf("expected workloads summary contributor id %q, got %+v", resourceID, summaryDecoded.TopContributors.CPU[0])+ }+ if summaryDecoded.TopContributors.CPU[0].ID == metricID {+ t.Fatalf("expected workloads summary contributor id to avoid raw metrics target %q", metricID)+ }+}+func TestContract_WorkloadsSummaryChartsNormalizeLongRangeMixedCadence(t *testing.T) {store := newTestMetricsStore(t)monitor, state, _ := newTestMonitor(t)diff --git a/internal/api/router.go b/internal/api/router.goindex 0a9e45c9a3..24215d4c6d 100644--- a/internal/api/router.go+++ b/internal/api/router.go@@ -5525,6 +5525,77 @@ func appContainerChartRequest(container *unifiedresources.DockerContainerView) (}, true}+func canonicalGuestResponseKey(resourceID, instance, node string, vmid int) string {+ trimmedInstance := strings.TrimSpace(instance)+ trimmedNode := strings.TrimSpace(node)+ if trimmedInstance != "" && trimmedNode != "" && vmid > 0 {+ return fmt.Sprintf("%s:%s:%d", trimmedInstance, trimmedNode, vmid)+ }+ return strings.TrimSpace(resourceID)+}++func vmChartMetricID(vm *unifiedresources.VMView) string {+ if vm == nil {+ return ""+ }++ if target := vm.MetricsTarget(); target != nil {+ if metricID := strings.TrimSpace(target.ResourceID); metricID != "" {+ return metricID+ }+ }++ return strings.TrimSpace(vm.SourceID())+}++func vmChartRequest(vm *unifiedresources.VMView) (string, monitoring.GuestChartRequest, bool) {+ if vm == nil {+ return "", monitoring.GuestChartRequest{}, false+ }++ responseKey := canonicalGuestResponseKey(vm.ID(), vm.Instance(), vm.Node(), vm.VMID())+ metricID := vmChartMetricID(vm)+ if responseKey == "" || metricID == "" {+ return "", monitoring.GuestChartRequest{}, false+ }++ return responseKey, monitoring.GuestChartRequest{+ InMemoryKey: metricID,+ SQLResourceID: metricID,+ }, true+}++func systemContainerChartMetricID(container *unifiedresources.ContainerView) string {+ if container == nil {+ return ""+ }++ if target := container.MetricsTarget(); target != nil {+ if metricID := strings.TrimSpace(target.ResourceID); metricID != "" {+ return metricID+ }+ }++ return strings.TrimSpace(container.SourceID())+}++func systemContainerChartRequest(container *unifiedresources.ContainerView) (string, monitoring.GuestChartRequest, bool) {+ if container == nil {+ return "", monitoring.GuestChartRequest{}, false+ }++ responseKey := canonicalGuestResponseKey(container.ID(), container.Instance(), container.Node(), container.VMID())+ metricID := systemContainerChartMetricID(container)+ if responseKey == "" || metricID == "" {+ return "", monitoring.GuestChartRequest{}, false+ }++ return responseKey, monitoring.GuestChartRequest{+ InMemoryKey: metricID,+ SQLResourceID: metricID,+ }, true+}+func capMetricPointSeriesByIndex(points []MetricPoint, maxPoints int) []MetricPoint {if len(points) <= maxPoints || maxPoints <= 0 {return points@@ -6155,6 +6226,7 @@ func (r *Router) handleWorkloadCharts(w http.ResponseWriter, req *http.Request)guestTypes := make(map[string]string)vmList := make([]*unifiedresources.VMView, 0)+ vmResponseKeys := make([]string, 0)vmRequests := make([]monitoring.GuestChartRequest, 0)for _, vm := range readState.VMs() {if vm == nil {@@ -6164,19 +6236,21 @@ func (r *Router) handleWorkloadCharts(w http.ResponseWriter, req *http.Request)continue}- sourceID := strings.TrimSpace(vm.SourceID())- if sourceID == "" {+ responseKey, request, ok := vmChartRequest(vm)+ if !ok {continue}vmList = append(vmList, vm)- vmRequests = append(vmRequests, monitoring.GuestChartRequest{InMemoryKey: sourceID, SQLResourceID: sourceID})+ vmResponseKeys = append(vmResponseKeys, responseKey)+ vmRequests = append(vmRequests, request)}vmBatchMetrics := monitor.GetGuestMetricsForChartBatch("vm", vmRequests, duration)- for _, vm := range vmList {- sourceID := strings.TrimSpace(vm.SourceID())- series := convertMetricsForChart(vmBatchMetrics[sourceID], &oldestTimestamp, maxPoints)- guestTypes[sourceID] = "vm"+ for idx, vm := range vmList {+ responseKey := vmResponseKeys[idx]+ metricID := vmRequests[idx].SQLResourceID+ series := convertMetricsForChart(vmBatchMetrics[metricID], &oldestTimestamp, maxPoints)+ guestTypes[responseKey] = "vm"if len(series["cpu"]) == 0 {series["cpu"] = []MetricPoint{{Timestamp: currentTime, Value: vm.CPUPercent()}}@@ -6186,10 +6260,11 @@ func (r *Router) handleWorkloadCharts(w http.ResponseWriter, req *http.Request)series["netout"] = []MetricPoint{{Timestamp: currentTime, Value: vm.NetOut()}}}updateOldestTimestampFromSeries(series, &oldestTimestamp)- chartData[sourceID] = series+ chartData[responseKey] = series}containerList := make([]*unifiedresources.ContainerView, 0)+ containerResponseKeys := make([]string, 0)containerRequests := make([]monitoring.GuestChartRequest, 0)for _, ct := range readState.Containers() {if ct == nil {@@ -6199,19 +6274,21 @@ func (r *Router) handleWorkloadCharts(w http.ResponseWriter, req *http.Request)continue}- sourceID := strings.TrimSpace(ct.SourceID())- if sourceID == "" {+ responseKey, request, ok := systemContainerChartRequest(ct)+ if !ok {continue}containerList = append(containerList, ct)- containerRequests = append(containerRequests, monitoring.GuestChartRequest{InMemoryKey: sourceID, SQLResourceID: sourceID})+ containerResponseKeys = append(containerResponseKeys, responseKey)+ containerRequests = append(containerRequests, request)}containerBatchMetrics := monitor.GetGuestMetricsForChartBatch("container", containerRequests, duration)- for _, ct := range containerList {- sourceID := strings.TrimSpace(ct.SourceID())- series := convertMetricsForChart(containerBatchMetrics[sourceID], &oldestTimestamp, maxPoints)- guestTypes[sourceID] = "system-container"+ for idx, ct := range containerList {+ responseKey := containerResponseKeys[idx]+ metricID := containerRequests[idx].SQLResourceID+ series := convertMetricsForChart(containerBatchMetrics[metricID], &oldestTimestamp, maxPoints)+ guestTypes[responseKey] = "system-container"if len(series["cpu"]) == 0 {series["cpu"] = []MetricPoint{{Timestamp: currentTime, Value: ct.CPUPercent()}}@@ -6221,7 +6298,7 @@ func (r *Router) handleWorkloadCharts(w http.ResponseWriter, req *http.Request)series["netout"] = []MetricPoint{{Timestamp: currentTime, Value: ct.NetOut()}}}updateOldestTimestampFromSeries(series, &oldestTimestamp)- chartData[sourceID] = series+ chartData[responseKey] = series}podList := make([]*unifiedresources.PodView, 0)@@ -7176,6 +7253,7 @@ func (r *Router) handleWorkloadsSummaryCharts(w http.ResponseWriter, req *http.R}vmList := make([]*unifiedresources.VMView, 0)+ vmResponseKeys := make([]string, 0)vmRequests := make([]monitoring.GuestChartRequest, 0)for _, vm := range readState.VMs() {if vm == nil {@@ -7184,16 +7262,18 @@ func (r *Router) handleWorkloadsSummaryCharts(w http.ResponseWriter, req *http.Rif !matchesSelectedNode(vm.Instance(), vm.Node()) {continue}- sourceID := strings.TrimSpace(vm.SourceID())- if sourceID == "" {+ responseKey, request, ok := vmChartRequest(vm)+ if !ok {continue}vmList = append(vmList, vm)- vmRequests = append(vmRequests, monitoring.GuestChartRequest{InMemoryKey: sourceID, SQLResourceID: sourceID})+ vmResponseKeys = append(vmResponseKeys, responseKey)+ vmRequests = append(vmRequests, request)}vmBatchMetrics := monitor.GetGuestMetricsForChartBatch("vm", vmRequests, duration)- for _, vm := range vmList {- sourceID := strings.TrimSpace(vm.SourceID())+ for idx, vm := range vmList {+ responseKey := vmResponseKeys[idx]+ metricID := vmRequests[idx].SQLResourceIDguestCounts.Total++if workloadSummaryStatusIsRunning("", vm.Status()) {guestCounts.Running++@@ -7202,7 +7282,7 @@ func (r *Router) handleWorkloadsSummaryCharts(w http.ResponseWriter, req *http.R}snapshot := workloadsSummarySnapshot{- id: sourceID,+ id: responseKey,name: strings.TrimSpace(vm.Name()),cpu: clampWorkloadPercent(vm.CPUPercent()),memory: clampWorkloadPercent(vm.MemoryPercent()),@@ -7210,10 +7290,10 @@ func (r *Router) handleWorkloadsSummaryCharts(w http.ResponseWriter, req *http.Rnetwork: clampNonNegativeWorkloadValue(vm.NetIn() + vm.NetOut()),}if snapshot.name == "" {- snapshot.name = sourceID+ snapshot.name = responseKey}- metrics := vmBatchMetrics[sourceID]+ metrics := vmBatchMetrics[metricID]cpuPoints := metrics["cpu"]if len(cpuPoints) == 0 {cpuPoints = []monitoring.MetricPoint{{Timestamp: currentTimeTime, Value: vm.CPUPercent()}}@@ -7248,6 +7328,7 @@ func (r *Router) handleWorkloadsSummaryCharts(w http.ResponseWriter, req *http.R}containerList := make([]*unifiedresources.ContainerView, 0)+ containerResponseKeys := make([]string, 0)containerRequests := make([]monitoring.GuestChartRequest, 0)for _, ct := range readState.Containers() {if ct == nil {@@ -7256,16 +7337,18 @@ func (r *Router) handleWorkloadsSummaryCharts(w http.ResponseWriter, req *http.Rif !matchesSelectedNode(ct.Instance(), ct.Node()) {continue}- sourceID := strings.TrimSpace(ct.SourceID())- if sourceID == "" {+ responseKey, request, ok := systemContainerChartRequest(ct)+ if !ok {continue}containerList = append(containerList, ct)- containerRequests = append(containerRequests, monitoring.GuestChartRequest{InMemoryKey: sourceID, SQLResourceID: sourceID})+ containerResponseKeys = append(containerResponseKeys, responseKey)+ containerRequests = append(containerRequests, request)}containerBatchMetrics := monitor.GetGuestMetricsForChartBatch("container", containerRequests, duration)- for _, ct := range containerList {- sourceID := strings.TrimSpace(ct.SourceID())+ for idx, ct := range containerList {+ responseKey := containerResponseKeys[idx]+ metricID := containerRequests[idx].SQLResourceIDguestCounts.Total++if workloadSummaryStatusIsRunning("", ct.Status()) {guestCounts.Running++@@ -7274,7 +7357,7 @@ func (r *Router) handleWorkloadsSummaryCharts(w http.ResponseWriter, req *http.R}snapshot := workloadsSummarySnapshot{- id: sourceID,+ id: responseKey,name: strings.TrimSpace(ct.Name()),cpu: clampWorkloadPercent(ct.CPUPercent()),memory: clampWorkloadPercent(ct.MemoryPercent()),@@ -7282,10 +7365,10 @@ func (r *Router) handleWorkloadsSummaryCharts(w http.ResponseWriter, req *http.Rnetwork: clampNonNegativeWorkloadValue(ct.NetIn() + ct.NetOut()),}if snapshot.name == "" {- snapshot.name = sourceID+ snapshot.name = responseKey}- metrics := containerBatchMetrics[sourceID]+ metrics := containerBatchMetrics[metricID]cpuPoints := metrics["cpu"]if len(cpuPoints) == 0 {cpuPoints = []monitoring.MetricPoint{{Timestamp: currentTimeTime, Value: ct.CPUPercent()}}diff --git a/internal/api/router_misc_additional_test.go b/internal/api/router_misc_additional_test.goindex a54de93fe8..6bbbeb5dfb 100644--- a/internal/api/router_misc_additional_test.go+++ b/internal/api/router_misc_additional_test.go@@ -774,6 +774,42 @@ func TestHandleWorkloadCharts_WorkloadOnlyPayloadAndNodeFilter(t *testing.T) {}},}}+ readState := monitor.GetUnifiedReadStateOrSnapshot()+ if readState == nil {+ t.Fatal("expected unified read state")+ }++ vmResponseKey := ""+ containerResponseKey := ""+ excludedResponseKey := ""+ for _, vm := range readState.VMs() {+ if vm == nil {+ continue+ }+ switch vm.Name() {+ case "vm-101":+ vmResponseKey, _, _ = vmChartRequest(vm)+ case "vm-202":+ excludedResponseKey, _, _ = vmChartRequest(vm)+ }+ }+ for _, ct := range readState.Containers() {+ if ct == nil {+ continue+ }+ if ct.Name() == "ct-301" {+ containerResponseKey, _, _ = systemContainerChartRequest(ct)+ }+ }+ if vmResponseKey == "" || containerResponseKey == "" || excludedResponseKey == "" {+ t.Fatalf(+ "expected canonical response keys for vm/container test fixtures, got vm=%q ct=%q excluded=%q",+ vmResponseKey,+ containerResponseKey,+ excludedResponseKey,+ )+ }+router := &Router{monitor: monitor}req := httptest.NewRequest(http.MethodGet, "/api/charts/workloads?range=5m", nil)@@ -804,13 +840,14 @@ func TestHandleWorkloadCharts_WorkloadOnlyPayloadAndNodeFilter(t *testing.T) {if len(decoded.DockerData) != 1 {t.Fatalf("expected 1 docker chart entry, got %d", len(decoded.DockerData))}- if decoded.GuestTypes["vm-101"] != "vm" {- t.Fatalf("expected vm guest type for vm-101, got %q", decoded.GuestTypes["vm-101"])+ if decoded.GuestTypes[vmResponseKey] != "vm" {+ t.Fatalf("expected vm guest type for %s, got %q", vmResponseKey, decoded.GuestTypes[vmResponseKey])}- if decoded.GuestTypes["ct-301"] != "system-container" {+ if decoded.GuestTypes[containerResponseKey] != "system-container" {t.Fatalf(- "expected system-container guest type for ct-301, got %q",- decoded.GuestTypes["ct-301"],+ "expected system-container guest type for %s, got %q",+ containerResponseKey,+ decoded.GuestTypes[containerResponseKey],)}if decoded.Stats.PointCounts.Total <= 0 {@@ -838,14 +875,168 @@ func TestHandleWorkloadCharts_WorkloadOnlyPayloadAndNodeFilter(t *testing.T) {if len(scoped.ChartData) != 2 {t.Fatalf("expected 2 scoped workload chart entries, got %d", len(scoped.ChartData))}- if _, ok := scoped.ChartData["vm-202"]; ok {- t.Fatalf("expected vm-202 to be excluded by node scope")+ if _, ok := scoped.ChartData[excludedResponseKey]; ok {+ t.Fatalf("expected %s to be excluded by node scope", excludedResponseKey)}if len(scoped.DockerData) != 1 {t.Fatalf("expected 1 scoped docker chart entry, got %d", len(scoped.DockerData))}}+func TestHandleWorkloadCharts_UsesCanonicalWorkloadIDsForVMwareVMs(t *testing.T) {+ monitor, state, history := newTestMonitor(t)+ now := time.Date(2026, time.April, 1, 12, 0, 0, 0, time.UTC)+ metricID := "vc-1:vm:vm-201"+ resourceID := "vm-vmware-1"++ history.AddGuestMetric(metricID, "cpu", 37, now.Add(-10*time.Minute))+ history.AddGuestMetric(metricID, "memory", 62, now.Add(-5*time.Minute))++ adapter := unifiedresources.NewMonitorAdapter(nil)+ adapter.PopulateSnapshotAndSupplemental(state.GetSnapshot(), map[unifiedresources.DataSource][]unifiedresources.IngestRecord{+ unifiedresources.SourceVMware: {+ {+ SourceID: metricID,+ Resource: unifiedresources.Resource{+ ID: resourceID,+ Type: unifiedresources.ResourceTypeVM,+ Name: "warehouse-api-01",+ Status: unifiedresources.StatusOnline,+ LastSeen: now,+ MetricsTarget: &unifiedresources.MetricsTarget{+ ResourceType: "vm",+ ResourceID: metricID,+ },+ VMware: &unifiedresources.VMwareData{+ ConnectionID: "vc-1",+ EntityType: "vm",+ ManagedObjectID: "vm-201",+ },+ },+ },+ },+ })+ setUnexportedField(t, monitor, "resourceStore", monitoring.ResourceStoreInterface(adapter))++ readState := monitor.GetUnifiedReadStateOrSnapshot()+ if readState == nil || len(readState.VMs()) != 1 || readState.VMs()[0] == nil {+ t.Fatalf("expected one VMware VM in unified read state, got %+v", readState)+ }+ resourceID, _, ok := vmChartRequest(readState.VMs()[0])+ if !ok {+ t.Fatal("expected canonical VMware vm chart request")+ }++ router := &Router{monitor: monitor}+ req := httptest.NewRequest(http.MethodGet, "/api/charts/workloads?range=1h", nil)+ rec := httptest.NewRecorder()+ router.handleWorkloadCharts(rec, req)++ if rec.Code != http.StatusOK {+ t.Fatalf("expected status %d, got %d: %s", http.StatusOK, rec.Code, rec.Body.String())+ }++ var decoded WorkloadChartsResponse+ if err := json.Unmarshal(rec.Body.Bytes(), &decoded); err != nil {+ t.Fatalf("unmarshal WorkloadChartsResponse: %v", err)+ }++ series, ok := decoded.ChartData[resourceID]+ if !ok {+ t.Fatalf("expected VMware workload chart keyed by canonical workload id %q, got %v", resourceID, decoded.ChartData)+ }+ if _, ok := decoded.ChartData[metricID]; ok {+ t.Fatalf("expected VMware metrics target id %q to stay out of workload chart response keys", metricID)+ }+ if decoded.GuestTypes[resourceID] != "vm" {+ t.Fatalf("expected guest type vm for %q, got %q", resourceID, decoded.GuestTypes[resourceID])+ }+ if len(series["cpu"]) == 0 {+ t.Fatalf("expected VMware cpu series for %q", resourceID)+ }+ if got := series["cpu"][len(series["cpu"])-1].Value; got != 37 {+ t.Fatalf("expected latest VMware cpu value 37, got %v", got)+ }+}++func TestHandleWorkloadsSummaryCharts_UsesCanonicalWorkloadIDsForVMwareVMs(t *testing.T) {+ monitor, state, history := newTestMonitor(t)+ now := time.Date(2026, time.April, 1, 12, 0, 0, 0, time.UTC)+ metricID := "vc-1:vm:vm-201"+ resourceID := "vm-vmware-1"++ history.AddGuestMetric(metricID, "cpu", 51, now.Add(-10*time.Minute))+ history.AddGuestMetric(metricID, "memory", 64, now.Add(-5*time.Minute))+ history.AddGuestMetric(metricID, "disk", 43, now.Add(-3*time.Minute))+ history.AddGuestMetric(metricID, "netin", 1200, now.Add(-2*time.Minute))+ history.AddGuestMetric(metricID, "netout", 800, now.Add(-2*time.Minute))++ adapter := unifiedresources.NewMonitorAdapter(nil)+ adapter.PopulateSnapshotAndSupplemental(state.GetSnapshot(), map[unifiedresources.DataSource][]unifiedresources.IngestRecord{+ unifiedresources.SourceVMware: {+ {+ SourceID: metricID,+ Resource: unifiedresources.Resource{+ ID: resourceID,+ Type: unifiedresources.ResourceTypeVM,+ Name: "warehouse-api-01",+ Status: unifiedresources.StatusOnline,+ LastSeen: now,+ MetricsTarget: &unifiedresources.MetricsTarget{+ ResourceType: "vm",+ ResourceID: metricID,+ },+ VMware: &unifiedresources.VMwareData{+ ConnectionID: "vc-1",+ EntityType: "vm",+ ManagedObjectID: "vm-201",+ },+ },+ },+ },+ })+ setUnexportedField(t, monitor, "resourceStore", monitoring.ResourceStoreInterface(adapter))++ readState := monitor.GetUnifiedReadStateOrSnapshot()+ if readState == nil || len(readState.VMs()) != 1 || readState.VMs()[0] == nil {+ t.Fatalf("expected one VMware VM in unified read state, got %+v", readState)+ }+ resourceID, _, ok := vmChartRequest(readState.VMs()[0])+ if !ok {+ t.Fatal("expected canonical VMware vm chart request")+ }++ router := &Router{monitor: monitor}+ req := httptest.NewRequest(http.MethodGet, "/api/charts/workloads-summary?range=1h", nil)+ rec := httptest.NewRecorder()+ router.handleWorkloadsSummaryCharts(rec, req)++ if rec.Code != http.StatusOK {+ t.Fatalf("expected status %d, got %d: %s", http.StatusOK, rec.Code, rec.Body.String())+ }++ var decoded WorkloadsSummaryChartsResponse+ if err := json.Unmarshal(rec.Body.Bytes(), &decoded); err != nil {+ t.Fatalf("unmarshal WorkloadsSummaryChartsResponse: %v", err)+ }++ if decoded.GuestCounts.Total != 1 || decoded.GuestCounts.Running != 1 {+ t.Fatalf("expected guestCounts total/running = 1/1, got %+v", decoded.GuestCounts)+ }+ if len(decoded.TopContributors.CPU) == 0 {+ t.Fatal("expected at least one cpu top contributor")+ }+ if decoded.TopContributors.CPU[0].ID != resourceID {+ t.Fatalf("expected cpu top contributor id %q, got %+v", resourceID, decoded.TopContributors.CPU[0])+ }+ if decoded.TopContributors.CPU[0].ID == metricID {+ t.Fatalf("expected workloads summary contributor id to avoid raw metrics target %q", metricID)+ }+ if got := decoded.TopContributors.CPU[0].Name; got != "warehouse-api-01" {+ t.Fatalf("expected cpu top contributor name warehouse-api-01, got %q", got)+ }+}+func TestHandleWorkloadCharts_IncludesKubernetesPods(t *testing.T) {prevMock := mock.IsMockEnabled()mock.SetEnabled(false)diff --git a/internal/unifiedresources/views.go b/internal/unifiedresources/views.goindex e5db9a4c12..d6697788e3 100644--- a/internal/unifiedresources/views.go+++ b/internal/unifiedresources/views.go@@ -110,6 +110,13 @@ func (v VMView) SourceID() string {return strings.TrimSpace(v.r.Proxmox.SourceID)}+func (v VMView) MetricsTarget() *MetricsTarget {+ if v.r == nil {+ return nil+ }+ return cloneMetricsTarget(v.r.MetricsTarget)+}+func (v VMView) Node() string {if v.r == nil || v.r.Proxmox == nil {return ""@@ -363,6 +370,13 @@ func (v ContainerView) SourceID() string {return strings.TrimSpace(v.r.Proxmox.SourceID)}+func (v ContainerView) MetricsTarget() *MetricsTarget {+ if v.r == nil {+ return nil+ }+ return cloneMetricsTarget(v.r.MetricsTarget)+}+func (v ContainerView) Node() string {if v.r == nil || v.r.Proxmox == nil {return ""diff --git a/internal/unifiedresources/views_test.go b/internal/unifiedresources/views_test.goindex a4f2dc442f..ba37d9dda1 100644--- a/internal/unifiedresources/views_test.go+++ b/internal/unifiedresources/views_test.go@@ -265,6 +265,32 @@ func TestView_VMViewAccessors(t *testing.T) {})}+func TestView_VMViewMetricsTargetAccessor(t *testing.T) {+ r := &Resource{+ ID: "vm-metrics",+ Type: ResourceTypeVM,+ Name: "provider-vm",+ MetricsTarget: &MetricsTarget{+ ResourceType: "vm",+ ResourceID: "vc-1:vm:vm-201",+ },+ }++ v := NewVMView(r)+ target := v.MetricsTarget()+ if target == nil {+ t.Fatal("expected vm metrics target")+ }+ if target.ResourceType != "vm" || target.ResourceID != "vc-1:vm:vm-201" {+ t.Fatalf("unexpected vm metrics target %+v", target)+ }++ target.ResourceID = "mutated"+ if got := v.MetricsTarget(); got == nil || got.ResourceID != "vc-1:vm:vm-201" {+ t.Fatalf("expected cloned vm metrics target, got %+v", got)+ }+}+func TestView_ContainerViewAccessors(t *testing.T) {now := time.Date(2026, 2, 10, 12, 1, 0, 0, time.UTC)lastBackup := time.Date(2026, 2, 9, 9, 0, 0, 0, time.UTC)@@ -437,6 +463,32 @@ func TestView_ContainerViewAccessors(t *testing.T) {})}+func TestView_ContainerViewMetricsTargetAccessor(t *testing.T) {+ r := &Resource{+ ID: "ct-metrics",+ Type: ResourceTypeSystemContainer,+ Name: "provider-ct",+ MetricsTarget: &MetricsTarget{+ ResourceType: "system-container",+ ResourceID: "lab:pve-1:201",+ },+ }++ v := NewContainerView(r)+ target := v.MetricsTarget()+ if target == nil {+ t.Fatal("expected container metrics target")+ }+ if target.ResourceType != "system-container" || target.ResourceID != "lab:pve-1:201" {+ t.Fatalf("unexpected container metrics target %+v", target)+ }++ target.ResourceID = "mutated"+ if got := v.MetricsTarget(); got == nil || got.ResourceID != "lab:pve-1:201" {+ t.Fatalf("expected cloned container metrics target, got %+v", got)+ }+}+func TestView_NodeViewAccessors(t *testing.T) {now := time.Date(2026, 2, 10, 12, 2, 0, 0, time.UTC)temp := 66.6diff --git a/tests/integration/tests/48-summary-hover-selection.spec.ts b/tests/integration/tests/48-summary-hover-selection.spec.tsindex 8f0ca95ff1..e2a94276f1 100644--- a/tests/integration/tests/48-summary-hover-selection.spec.ts+++ b/tests/integration/tests/48-summary-hover-selection.spec.ts@@ -127,6 +127,14 @@ async function hoverRowUntilSummaryHighlights(throw new Error("Unable to find a row that maps to summary highlight state");}+async function dispatchRowHover(+ row: import("@playwright/test").Locator,+): Promise<void> {+ await row.dispatchEvent("mouseenter");+ await row.dispatchEvent("mouseover");+ await row.dispatchEvent("focusin");+}+async function hoverSummaryChartUntilActiveId(page: import("@playwright/test").Page,summary: import("@playwright/test").Locator,@@ -295,6 +303,19 @@ test.describe.serial("Summary hover selection", () => {expect(workloadRowId).not.toBe("");await expectActiveIsolatedLineCards(workloadsSummary, 2);+ const vmwareWorkloadRow = page+ .locator('tr[data-guest-id^="vm-"]', { hasText: "warehouse-api-01" })+ .first();+ await expect(vmwareWorkloadRow).toBeVisible();+ const vmwareWorkloadId = await readSummarySeriesId(+ vmwareWorkloadRow,+ "data-guest-id",+ );+ expect(vmwareWorkloadId).not.toBe("");+ await dispatchRowHover(vmwareWorkloadRow);+ await expectSummaryHighlightCount(workloadsSummary, vmwareWorkloadId, 4);+ await expectActiveIsolatedLineCards(workloadsSummary, 2);+await page.goto("/storage", { waitUntil: "domcontentloaded" });const storageSummary = page.getByTestId("storage-summary");await expect(storageSummary).toBeVisible();