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
docker(drawer): unlock metrics history and container facts for app-containers
rcourtmane12b7507e2d0
diff --git a/frontend-modern/src/components/Infrastructure/ResourceDetailSummary.tsx b/frontend-modern/src/components/Infrastructure/ResourceDetailSummary.tsxindex 50d49bd729..74ab155541 100644--- a/frontend-modern/src/components/Infrastructure/ResourceDetailSummary.tsx+++ b/frontend-modern/src/components/Infrastructure/ResourceDetailSummary.tsx@@ -3,7 +3,7 @@ import type { Component } from 'solid-js';import type { Resource } from '@/types/resource';import { Card } from '@/components/shared/Card';import { TagBadges } from '@/components/shared/TagBadges';-import { formatUptime } from '@/utils/format';+import { formatRelativeTime, formatUptime } from '@/utils/format';import { formatInteger } from './resourceDetailMappers';import type { UseResourceDetailDrawerStateResult } from './useResourceDetailDrawerState';@@ -13,6 +13,131 @@ interface ResourceSummaryPresentationProps {showPlatformId: boolean;}+// Docker / Podman containers carry runtime facts (image, restart count,+// created-at, compose membership, labels) that no generic summary row+// surfaces. v5 rendered all of these in the container drawer; the unified+// payload still ships them on resource.docker.+const dockerContainerMeta = (resource: Resource): NonNullable<Resource['docker']> | null => {+ if (resource.type !== 'app-container') return null;+ const docker = resource.docker;+ if (!docker) return null;+ if (!docker.containerId && !docker.containerState && !docker.image) return null;+ return docker;+};++const composeLabelValue = (+ labels: Record<string, string> | undefined,+ suffix: 'project' | 'service',+): string =>+ (+ labels?.[`com.docker.compose.${suffix}`] ||+ labels?.[`io.podman.compose.${suffix}`] ||+ ''+ ).trim();++const dockerCreatedAtMillis = (docker: NonNullable<Resource['docker']>): number | null => {+ const raw = (docker.createdAt || '').trim();+ if (!raw) return null;+ const parsed = Date.parse(raw);+ return Number.isFinite(parsed) ? parsed : null;+};++const DockerContainerSummarySection: Component<{ docker: NonNullable<Resource['docker']> }> = (+ props,+) => {+ const labels = () => props.docker.labels ?? {};+ const labelEntries = () => Object.entries(labels());+ const createdAt = () => dockerCreatedAtMillis(props.docker);+ const restartCount = () => props.docker.restartCount;++ return (+ <tbody+ data-testid="resource-docker-container-section"+ class="divide-y divide-border border-t border-border"+ >+ <tr class="bg-surface-alt">+ <th+ colspan="2"+ class="px-2 py-1 text-left text-[10px] font-semibold uppercase tracking-wide text-muted"+ >+ Container+ </th>+ </tr>+ <Show when={(props.docker.image || '').trim()}>+ <tr>+ <td class="w-[38%] px-2 py-1 text-muted">Image</td>+ <td class="px-2 py-1 text-right font-medium text-base-content" title={props.docker.image}>+ <span class="block truncate">{props.docker.image}</span>+ </td>+ </tr>+ </Show>+ <Show when={typeof restartCount() === 'number'}>+ <tr>+ <td class="px-2 py-1 text-muted">Restarts</td>+ <td+ class={`px-2 py-1 text-right font-medium ${+ (restartCount() ?? 0) > 5+ ? 'text-red-600 dark:text-red-400'+ : 'text-base-content'+ }`}+ >+ {formatInteger(restartCount())}+ </td>+ </tr>+ </Show>+ <Show when={createdAt()}>+ {(created) => (+ <tr>+ <td class="px-2 py-1 text-muted">Created</td>+ <td+ class="px-2 py-1 text-right font-medium text-base-content"+ title={new Date(created()).toLocaleString()}+ >+ {formatRelativeTime(created())}+ </td>+ </tr>+ )}+ </Show>+ <Show when={composeLabelValue(labels(), 'project')}>+ <tr>+ <td class="px-2 py-1 text-muted">Compose project</td>+ <td class="px-2 py-1 text-right font-medium text-base-content">+ {composeLabelValue(labels(), 'project')}+ </td>+ </tr>+ </Show>+ <Show when={composeLabelValue(labels(), 'service')}>+ <tr>+ <td class="px-2 py-1 text-muted">Compose service</td>+ <td class="px-2 py-1 text-right font-medium text-base-content">+ {composeLabelValue(labels(), 'service')}+ </td>+ </tr>+ </Show>+ <Show when={labelEntries().length > 0}>+ <tr>+ <td class="px-2 py-1 align-top text-muted">Labels</td>+ <td class="px-2 py-1">+ <div class="flex flex-wrap justify-end gap-1">+ <For each={labelEntries()}>+ {([key, value]) => (+ <span+ class="inline-flex max-w-full items-center truncate rounded bg-surface-alt px-1.5 py-0.5 text-[10px]"+ title={value ? `${key}: ${value}` : key}+ >+ {key}+ <Show when={value}>: {value}</Show>+ </span>+ )}+ </For>+ </div>+ </td>+ </tr>+ </Show>+ </tbody>+ );+};+export const InlineResourceSummaryTables: Component<ResourceSummaryPresentationProps> = (props) => (<divdata-testid="resource-summary-section"@@ -112,6 +237,9 @@ export const InlineResourceSummaryTables: Component<ResourceSummaryPresentationP</tr></Show></tbody>+ <Show when={dockerContainerMeta(props.resource)}>+ {(docker) => <DockerContainerSummarySection docker={docker()} />}+ </Show><tbodydata-testid="resource-identity-section"class="divide-y divide-border border-t border-border"diff --git a/frontend-modern/src/components/Infrastructure/__tests__/ResourceDetailDrawer.docker-container.test.tsx b/frontend-modern/src/components/Infrastructure/__tests__/ResourceDetailDrawer.docker-container.test.tsxnew file mode 100644index 0000000000..22de9bf110--- /dev/null+++ b/frontend-modern/src/components/Infrastructure/__tests__/ResourceDetailDrawer.docker-container.test.tsx@@ -0,0 +1,141 @@+import { cleanup, fireEvent, render, screen, within } from '@solidjs/testing-library';+import { afterEach, describe, expect, it, vi } from 'vitest';+import type { Resource } from '@/types/resource';+import { ResourceDetailDrawer } from '../ResourceDetailDrawer';++vi.mock('@/components/Workloads/GuestDrawerHistory', () => ({+ GuestDrawerHistory: (props: {+ target: { resourceType: string; resourceId: string } | null;+ range: string;+ fallbackMetrics?: Record<string, number | undefined>;+ }) => (+ <div+ data-testid="container-history"+ data-resource-type={props.target?.resourceType}+ data-resource-id={props.target?.resourceId}+ data-range={props.range}+ data-cpu={props.fallbackMetrics?.cpu}+ />+ ),+ GuestDrawerHistoryRangeSelect: (props: {+ range: string;+ onRangeChange: (range: string) => void;+ }) => (+ <select+ aria-label="History range"+ value={props.range}+ onChange={(event) => props.onRangeChange(event.currentTarget.value)}+ >+ <option value="24h">24 hours</option>+ <option value="7d">7 days</option>+ </select>+ ),+}));++const resource = (overrides: Partial<Resource>): Resource =>+ ({+ id: overrides.id ?? 'app-container-1',+ name: overrides.name ?? overrides.id ?? 'app-container-1',+ displayName: overrides.displayName ?? overrides.name ?? overrides.id ?? 'app-container-1',+ type: overrides.type ?? 'app-container',+ platformId: 'docker',+ platformType: 'docker',+ sourceType: 'agent',+ status: 'online',+ lastSeen: 1_700_000_000_000,+ ...overrides,+ }) as Resource;++afterEach(() => {+ cleanup();+ vi.clearAllMocks();+});++describe('ResourceDetailDrawer for Docker containers', () => {+ it('adds a metrics history tab for app-containers with a metrics target', async () => {+ render(() => (+ <ResourceDetailDrawer+ resource={resource({+ id: 'app-container-web',+ name: 'edge-web',+ metricsTarget: { resourceType: 'app-container', resourceId: 'abc123def456' },+ cpu: { current: 75 },+ })}+ />+ ));++ await fireEvent.click(screen.getByRole('tab', { name: 'History' }));++ const history = screen.getByTestId('container-history');+ expect(history).toHaveAttribute('data-resource-type', 'app-container');+ expect(history).toHaveAttribute('data-resource-id', 'abc123def456');+ expect(history).toHaveAttribute('data-cpu', '75');+ });++ it('omits the history tab when no metrics target resolves', () => {+ render(() => (+ <ResourceDetailDrawer+ resource={resource({+ id: 'docker-image-1',+ type: 'docker-image',+ name: 'nginx:latest',+ })}+ />+ ));++ expect(screen.queryByRole('tab', { name: 'History' })).not.toBeInTheDocument();+ });++ it('renders container runtime facts in the table-row summary', () => {+ render(() => (+ <ResourceDetailDrawer+ presentation="table-row"+ resource={resource({+ id: 'app-container-web',+ name: 'edge-web',+ docker: {+ containerId: 'abc123def456',+ containerState: 'running',+ image: 'ghcr.io/example/edge-web:2026.05',+ restartCount: 7,+ createdAt: '2026-04-13T01:14:01Z',+ labels: {+ 'com.docker.compose.project': 'orion',+ 'com.docker.compose.service': 'web',+ 'traefik.enable': 'true',+ },+ },+ })}+ />+ ));++ const section = screen.getByTestId('resource-docker-container-section');+ expect(within(section).getByText('Image')).toBeInTheDocument();+ expect(within(section).getByText('ghcr.io/example/edge-web:2026.05')).toBeInTheDocument();+ expect(within(section).getByText('Restarts')).toBeInTheDocument();+ expect(within(section).getByText('7')).toHaveClass('text-red-600');+ expect(within(section).getByText('Created')).toBeInTheDocument();+ expect(within(section).getByText(/ago$/)).toBeInTheDocument();+ expect(within(section).getByText('Compose project')).toBeInTheDocument();+ expect(within(section).getByText('orion')).toBeInTheDocument();+ expect(within(section).getByText('Compose service')).toBeInTheDocument();+ expect(within(section).getByText('Labels')).toBeInTheDocument();+ expect(within(section).getByText(/traefik\.enable/)).toBeInTheDocument();+ });++ it('does not render the container section for non-container resources', () => {+ render(() => (+ <ResourceDetailDrawer+ presentation="table-row"+ resource={resource({+ id: 'docker-volume-1',+ type: 'docker-volume',+ name: 'app-data',+ docker: { volumeName: 'app-data', driver: 'local', createdAt: '2026-04-13T01:14:01Z' },+ })}+ />+ ));++ expect(screen.queryByTestId('resource-docker-container-section')).not.toBeInTheDocument();+ });+});diff --git a/frontend-modern/src/components/Infrastructure/resourceDetailDrawerMetricsHistoryModel.ts b/frontend-modern/src/components/Infrastructure/resourceDetailDrawerMetricsHistoryModel.tsindex d5f196decf..7291771371 100644--- a/frontend-modern/src/components/Infrastructure/resourceDetailDrawerMetricsHistoryModel.ts+++ b/frontend-modern/src/components/Infrastructure/resourceDetailDrawerMetricsHistoryModel.ts@@ -27,16 +27,17 @@ export const getResourceMetricsHistoryTarget = (return null;};+// Any resource that resolves a metrics history target can chart history —+// the backend stores and serves series for every type resolveMetricsTarget+// hands out (agent, vm, system-container, app-container, pod, disk, ceph).+// Gating on type === 'agent' silently hid history for Docker containers+// even though the store records their CPU/memory/disk/IO samples.export const resourceSupportsMetricsHistory = (resource: Resource): boolean =>- resource.type === 'agent' && getResourceMetricsHistoryTarget(resource) !== null;+ getResourceMetricsHistoryTarget(resource) !== null;export const getResourceMetricsHistoryFallbackMetrics = (resource: Resource,): Record<string, number | undefined> => {- if (resource.type !== 'agent') {- return {};- }-return {cpu: finiteMetric(resource.cpu?.current),memory: resource.memory ? finiteMetric(getMemoryPercent(resource)) : undefined,