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(proxmox): restore PBS host history
pulse-triage[bot]118c90d1f0df
diff --git a/frontend-modern/src/features/proxmox/ProxmoxBackupServersTable.tsx b/frontend-modern/src/features/proxmox/ProxmoxBackupServersTable.tsxindex 90cd83968a..f486ae8ff1 100644--- a/frontend-modern/src/features/proxmox/ProxmoxBackupServersTable.tsx+++ b/frontend-modern/src/features/proxmox/ProxmoxBackupServersTable.tsx@@ -23,6 +23,7 @@ import {} from '@/features/platformPage/PlatformResourceDetailTableRow';import type { PBSBackup } from '@/types/api';import type { Resource, ResourcePBSDatastore } from '@/types/resource';+import { getNormalizedIdentityLookupVariants } from '@/utils/resourceIdentity';import type { StatusIndicatorVariant } from '@/utils/status';import { useObservedElementWidth } from '@/hooks/useObservedElementWidth';@@ -102,6 +103,79 @@ function usageToneClass(pct: number | undefined): string {return 'text-base-content';}+const identityValues = (resource: Resource): Array<string | undefined> => [+ resource.canonicalIdentity?.hostname,+ resource.canonicalIdentity?.platformId,+ resource.identity?.hostname,+ ...(resource.identity?.ips ?? []),+ resource.agent?.hostname,+ resource.pbs?.hostname,+ resource.pbs?.instanceId,+ resource.platformId,+ resource.name,+ resource.displayName,+];++const identityTokens = (resource: Resource): Set<string> =>+ new Set(identityValues(resource).flatMap((value) => getNormalizedIdentityLookupVariants(value)));++const stringValues = (...candidates: unknown[]): string[] =>+ candidates.flatMap((candidate) =>+ Array.isArray(candidate)+ ? candidate.filter((value): value is string => typeof value === 'string')+ : [],+ );++const uniquelyCorrelatedAgent = (+ server: Resource,+ candidates: readonly Resource[],+): Resource | undefined => {+ const serverTokens = identityTokens(server);+ if (serverTokens.size === 0) return undefined;+ const matches = candidates.filter((candidate) => {+ if (candidate.type !== 'agent') return false;+ for (const token of identityTokens(candidate)) {+ if (serverTokens.has(token)) return true;+ }+ return false;+ });+ return matches.length === 1 ? matches[0] : undefined;+};++const mergePBSAgentPresentation = (server: Resource, agent: Resource): Resource => {+ const serverPlatform = server.platformData ?? {};+ const agentPlatform = agent.platformData ?? {};+ const sources = Array.from(+ new Set([+ ...stringValues(server.sources, serverPlatform.sources),+ ...stringValues(agent.sources, agentPlatform.sources),+ ]),+ );+ return {+ ...server,+ sourceType: 'hybrid',+ sources,+ cpu: agent.cpu ?? server.cpu,+ memory: agent.memory ?? server.memory,+ disk: agent.disk ?? server.disk,+ network: agent.network ?? server.network,+ diskIO: agent.diskIO ?? server.diskIO,+ temperature: agent.temperature ?? server.temperature,+ uptime: agent.uptime ?? server.uptime,+ agent: agent.agent ?? agentPlatform.agent ?? server.agent,+ metricsTarget: agent.metricsTarget ?? server.metricsTarget,+ discoveryTarget: agent.discoveryTarget ?? server.discoveryTarget,+ lastSeen: Math.max(server.lastSeen, agent.lastSeen),+ platformData: {+ ...agentPlatform,+ ...serverPlatform,+ sources,+ agent: agent.agent ?? agentPlatform.agent ?? serverPlatform.agent,+ pbs: server.pbs ?? serverPlatform.pbs,+ },+ };+};+export function buildBackupServerRows(servers: readonly Resource[],backups: readonly PBSBackup[] = [],@@ -123,6 +197,10 @@ export function buildBackupServerRows(// datastore renders as a phantom offline "server" row.const sortedServers = servers.filter((resource) => resource.type === 'pbs')+ .map((server) => {+ const agent = uniquelyCorrelatedAgent(server, servers);+ return agent ? mergePBSAgentPresentation(server, agent) : server;+ }).slice().sort((left, right) => left.name.localeCompare(right.name) || left.id.localeCompare(right.id));for (const server of sortedServers) {diff --git a/frontend-modern/src/features/proxmox/__tests__/ProxmoxBackupServersTable.drawer.test.tsx b/frontend-modern/src/features/proxmox/__tests__/ProxmoxBackupServersTable.drawer.test.tsxindex 8061513bfa..31d6e1b8fd 100644--- a/frontend-modern/src/features/proxmox/__tests__/ProxmoxBackupServersTable.drawer.test.tsx+++ b/frontend-modern/src/features/proxmox/__tests__/ProxmoxBackupServersTable.drawer.test.tsx@@ -14,6 +14,8 @@ vi.mock('@/components/Infrastructure/ResourceDetailDrawer', () => ({data-testid="pbs-resource-detail"data-resource-id={props.resource.id}data-host-details-open={String(props.initialShowHostDetails === true)}+ data-agent-id={props.resource.agent?.agentId}+ data-metrics-resource-id={props.resource.metricsTarget?.resourceId}><button type="button" onClick={props.onClose}>Close details@@ -66,4 +68,75 @@ describe('ProxmoxBackupServersTable details', () => {fireEvent.click(screen.getByRole('button', { name: 'Close details' }));expect(screen.queryByTestId('pbs-resource-detail')).not.toBeInTheDocument();});++ it('uses the uniquely correlated agent resource for host details and metrics history', () => {+ const pbs = makePbsResource();+ pbs.sources = ['pbs'];+ pbs.agent = undefined;+ pbs.metricsTarget = { resourceType: 'agent', resourceId: 'pbs-main' };+ pbs.platformData = {+ sources: ['pbs'],+ pbs: { instanceId: 'pbs-main', hostname: 'pbs-main', datastoreCount: 1 },+ };+ const agent = {+ id: 'agent-host-1',+ type: 'agent',+ name: 'pbs-main.local',+ displayName: 'PBS host',+ platformId: 'agent-host-1',+ platformType: 'proxmox-pbs',+ sourceType: 'hybrid',+ sources: ['agent', 'pbs'],+ status: 'online',+ lastSeen: pbs.lastSeen + 1_000,+ agent: { agentId: 'agent-pbs-1', hostname: 'pbs-main.local', osName: 'Debian GNU/Linux' },+ metricsTarget: { resourceType: 'agent', resourceId: 'agent-pbs-1' },+ platformData: {+ sources: ['agent', 'pbs'],+ agent: { agentId: 'agent-pbs-1', hostname: 'pbs-main.local' },+ },+ } as Resource;++ render(() => <ProxmoxBackupServersTable servers={[pbs, agent]} />);+ fireEvent.click(screen.getByRole('button', { name: 'Expand details for pbs-main' }));++ const detail = screen.getByTestId('pbs-resource-detail');+ expect(detail).toHaveAttribute('data-resource-id', 'pbs-1');+ expect(detail).toHaveAttribute('data-agent-id', 'agent-pbs-1');+ expect(detail).toHaveAttribute('data-metrics-resource-id', 'agent-pbs-1');+ });++ it('does not guess when two agent resources share the PBS hostname', () => {+ const pbs = makePbsResource();+ pbs.sources = ['pbs'];+ pbs.agent = undefined;+ pbs.metricsTarget = { resourceType: 'agent', resourceId: 'pbs-main' };+ const candidate = (id: string): Resource =>+ ({+ id,+ type: 'agent',+ name: 'pbs-main.local',+ displayName: id,+ platformId: id,+ platformType: 'proxmox-pbs',+ sourceType: 'hybrid',+ sources: ['agent', 'pbs'],+ status: 'online',+ lastSeen: pbs.lastSeen,+ agent: { agentId: id, hostname: 'pbs-main.local' },+ metricsTarget: { resourceType: 'agent', resourceId: id },+ }) as Resource;++ render(() => (+ <ProxmoxBackupServersTable+ servers={[pbs, candidate('agent-pbs-a'), candidate('agent-pbs-b')]}+ />+ ));+ fireEvent.click(screen.getByRole('button', { name: 'Expand details for pbs-main' }));++ expect(screen.getByTestId('pbs-resource-detail')).toHaveAttribute(+ 'data-metrics-resource-id',+ 'pbs-main',+ );+ });});