Skip to content

armgit / Pulse

Public Imported from GitHub
0

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.

Show the active-alert dot on threshold rows again

rcourtman042e3cc2fde3
diff --git a/docs/release-control/v6/internal/subsystems/alerts.md b/docs/release-control/v6/internal/subsystems/alerts.md
index 1bd248e31a..aef80568bb 100644
--- a/docs/release-control/v6/internal/subsystems/alerts.md
+++ b/docs/release-control/v6/internal/subsystems/alerts.md
@@ -5163,6 +5163,31 @@ had no alert highlighting at all. `getAlertStyles` keeps its
id-plus-node-name matching for the platform tables whose alerts are keyed that
way.
+### Threshold rows mark the limits whose alerts are open
+
+On Alerts > Thresholds a metric value carries a pulsing "Active alert" dot
+while an alert on that metric is open. `useThresholdsTableState` indexes the
+websocket `activeAlerts` map by each alert's `resourceId` and `type`
+(`indexActiveMetricAlerts` in
+`frontend-modern/src/features/alerts/thresholds/thresholdsResourceModel.ts`)
+and asks `thresholdRowHasActiveAlert` per cell. The map is keyed by alert ID
+(`<resource>::metric-threshold:<metric>` for threshold alerts), so a row never
+rebuilds a key; until 2026-11-01 it looked up `<row id>-<metric>`, a key no
+alert has carried since canonical metric IDs, and no row ever showed the dot.
+A row matches on `alertResourceIds` when its data projector sets them, else on
+its own id. Machine rows answer to `agent:<host ID>` (CheckHost's
+`hostResourceID`, while the row and its override keep the bare host ID) and to
+their disks' usage and SMART temperature alerts nested under it
+(`agent:<host>/disk:` and `agent:<host>/disk_temp:`), because the machine's
+Disk % and Disk Temp limits are what those disks inherit; sensor and RAID
+children have limits of their own. Machine disk and sensor rows are keyed on
+the alert resource ID already. Proxmox node rows answer only to their Proxmox
+node ID: a node merged with its Pulse agent hands CPU, memory and disk to the
+agent, and those alerts mark the Machines row whose limits judge them, never
+the node row's unused limits. Guest rows answer to
+`getUnifiedResourceAlertResourceIds` (`frontend-modern/src/utils/alerts.ts`),
+the exact keys `getOwnAlertsForUnifiedResource` matches.
+
### SMART temperature continuity and pending-only policy intervals
Disk temperature activation/grace and recovery require continuous accepted
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
index e6b6abe195..d6a77b83bb 100644
--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md
+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
@@ -6192,7 +6192,12 @@ its text like the other drawers. Their table rows (Docker hosts, Machines,
Kubernetes nodes) take the platform host rows'
red (critical) or yellow tint from the same set through
`getUnifiedResourceAlertStyles`, only for unacknowledged alerts and never on
-an expanded row, so a row and its drawer agree. The remaining Overview rows are additive
+an expanded row, so a row and its drawer agree. The Alerts > Thresholds
+"Active alert" dot reads the same map by each alert's `resourceId` and
+`type`, never by rebuilding an alert-ID key; a threshold row names the
+resource IDs its alerts are raised on (`alertResourceIds`, with
+`getUnifiedResourceAlertResourceIds` for unified guest rows) and machine rows
+also answer for their disks' alerts. The remaining Overview rows are additive
operator context that the parent table row cannot carry, such as OS/runtime,
Pulse observation or action coverage, primary reachability, protection gaps,
pending updates, or an identified service. Routine health, placement, and
diff --git a/frontend-modern/browser-verification/38356faf94f61668.json b/frontend-modern/browser-verification/38356faf94f61668.json
new file mode 100644
index 0000000000..8451a06903
--- /dev/null
+++ b/frontend-modern/browser-verification/38356faf94f61668.json
@@ -0,0 +1,53 @@
+{
+ "version": 1,
+ "base_sha": "c93d188aff3c0e6c10839a29bcdfe7f4f3d49373",
+ "verified_at": "2026-11-01T13:42:00Z",
+ "result": "passed",
+ "changed_paths": [
+ "frontend-modern/src/components/Alerts/AlertResourceTableMobile.tsx",
+ "frontend-modern/src/components/Alerts/AlertResourceTableRow.tsx",
+ "frontend-modern/src/components/Alerts/ResourceTable.tsx",
+ "frontend-modern/src/features/alerts/thresholds/hooks/useThresholdsGuestData.ts",
+ "frontend-modern/src/features/alerts/thresholds/hooks/useThresholdsHostData.ts",
+ "frontend-modern/src/features/alerts/thresholds/hooks/useThresholdsTableState.ts",
+ "frontend-modern/src/features/alerts/thresholds/tableTypes.ts",
+ "frontend-modern/src/features/alerts/thresholds/thresholdsResourceModel.ts",
+ "frontend-modern/src/utils/alerts.ts"
+ ],
+ "content_sha256": {
+ "frontend-modern/src/components/Alerts/AlertResourceTableMobile.tsx": "fe131d17441c84233ceb74c54df84c6bfcbacc5fad219f8d87b67b6989f91e02",
+ "frontend-modern/src/components/Alerts/AlertResourceTableRow.tsx": "0d0473a9d75b46eeef68c1f0886c857fa82539ff01b7b02d1500f4bb259f0410",
+ "frontend-modern/src/components/Alerts/ResourceTable.tsx": "3f7f4dff833191c07b83cefeeece8282b74b3ab07ef59eab38577b0fbe3ce6f6",
+ "frontend-modern/src/features/alerts/thresholds/hooks/useThresholdsGuestData.ts": "658d8d0290241da9c73a04b89854fad87f26f76ea401b768cf373616a9f55daf",
+ "frontend-modern/src/features/alerts/thresholds/hooks/useThresholdsHostData.ts": "c0e926fe6f30bb35af04be10414f3d8c9382e140b5b30662e07c19a6ecccfa1d",
+ "frontend-modern/src/features/alerts/thresholds/hooks/useThresholdsTableState.ts": "4845d81add01cd5bc7111390acfd6f37095c94bce57e9b01976663258d049a28",
+ "frontend-modern/src/features/alerts/thresholds/tableTypes.ts": "4b5a3141aa1029451671097df2c3bd20864fdc180863954075a4ccd6b799bd0f",
+ "frontend-modern/src/features/alerts/thresholds/thresholdsResourceModel.ts": "4e2d546bf99c1a9ad6b838b6a854a7efc8d837b1f1102609a112b15ee3fce2a2",
+ "frontend-modern/src/utils/alerts.ts": "a212a0c87912af3943d18ee2736cc65aa8e48dcb209877557cc98cb45ad08786"
+ },
+ "routes": [
+ "/alerts/thresholds/systems",
+ "/alerts/thresholds/proxmox"
+ ],
+ "viewports": [
+ {
+ "width": 1440,
+ "height": 900
+ },
+ {
+ "width": 375,
+ "height": 812
+ }
+ ],
+ "states": [
+ "Private mock stack on pulse-dev (PULSE_MOCK_MODE, 4 nodes) built from this change with its embedded frontend, viewed in the Claude desktop Browser pane (Chromium) over an SSH tunnel. Thresholds lowered through PUT /api/alerts/config (node/agent CPU 3%, memory 10%, agent disk 5%, node temperature 20C, guest CPU 3%) plus one sensor override on agent:host-linux-1/sensor:<hex>, so canonical metric-threshold alerts fired on nodes, machines, machine disks, a machine sensor and guests.",
+ "Before (main build, same stack and config): Machines and Proxmox tabs rendered zero [title=\"Active alert\"] elements with 60+ metric alerts open.",
+ "After, Machines tab at 1440x900: machine cards (AlertResourceTableMobile at that container width) lit CPU/Memory/Disk exactly where agent:<host> cpu/memory alerts or nested agent:<host>/disk: alerts were open; a scripted cross-check of all 88 rendered machine metric cells against /api/alerts/active found 0 mismatches (39 lit). Machine Disks table rows (AlertResourceTableRow) showed 13 dots for 13 open agent disk alerts; Machine Sensors table showed 1 dot for the 1 open sensor alert. backup-vault (PBS, no host-agent alerts) correctly showed none.",
+ "After, Proxmox tab at 1440x900: node cards lit only Temp for the 4 open node temperature alerts; linked-agent CPU/memory/disk alerts did not light the node rows' unused limits. Guest rows lit CPU; 69 rendered guest metric cells cross-checked against open alerts with 0 mismatches.",
+ "Narrow pass at 375x812 on the Machines tab: dots render beside the values in the card layout, no horizontal page overflow (scrollWidth == innerWidth)."
+ ],
+ "interactions": [
+ "Opened the Machines and Proxmox threshold tabs, clicked Expand all, scrolled the app shell to the lit rows, and compared every rendered dot to the live /api/alerts/active list by resourceId and type.",
+ "Reloaded after swapping the main build for the fixed build on the same mock configuration (before/after)."
+ ]
+}
diff --git a/frontend-modern/src/components/Alerts/AlertResourceTableMobile.tsx b/frontend-modern/src/components/Alerts/AlertResourceTableMobile.tsx
index bc6cd77673..9913cabf42 100644
--- a/frontend-modern/src/components/Alerts/AlertResourceTableMobile.tsx
+++ b/frontend-modern/src/components/Alerts/AlertResourceTableMobile.tsx
@@ -144,7 +144,7 @@ export function AlertResourceTableMobile(props: AlertResourceTableMobileProps) {
value <= 0 ? 'Off' : props.table.formatMetricValue(metric, value);
const MetricValueWithHeat = (metricProps: {
- resourceId: string;
+ resource: Resource;
metric: string;
value: number;
isOverridden: boolean;
@@ -168,7 +168,7 @@ export function AlertResourceTableMobile(props: AlertResourceTableMobileProps) {
>
{displayText}
</span>
- <Show when={props.table.hasActiveAlert(metricProps.resourceId, metricProps.metric)}>
+ <Show when={props.table.hasActiveAlert(metricProps.resource, metricProps.metric)}>
<div class="w-1.5 h-1.5 rounded-full bg-red-500 animate-pulse" title="Active alert" />
</Show>
</div>
@@ -529,7 +529,7 @@ export function AlertResourceTableMobile(props: AlertResourceTableMobileProps) {
aria-label={`Edit ${column} threshold for ${getAlertResourceLabel(resource)}: ${metricValueText(metric, displayValue(metric))}`}
>
<MetricValueWithHeat
- resourceId={resource.id}
+ resource={resource}
metric={metric}
value={displayValue(metric)}
isOverridden={isOverridden(metric)}
diff --git a/frontend-modern/src/components/Alerts/AlertResourceTableRow.tsx b/frontend-modern/src/components/Alerts/AlertResourceTableRow.tsx
index f8f10400ff..5c52ad688a 100644
--- a/frontend-modern/src/components/Alerts/AlertResourceTableRow.tsx
+++ b/frontend-modern/src/components/Alerts/AlertResourceTableRow.tsx
@@ -52,7 +52,7 @@ interface AlertResourceTableRowProps {
editingThresholds: () => Record<string, number | undefined>;
setEditingThresholds: (value: Record<string, number | undefined>) => void;
formatMetricValue: (metric: string, value: number | undefined) => string;
- hasActiveAlert: (resourceId: string, metric: string) => boolean;
+ hasActiveAlert: (resource: Resource, metric: string) => boolean;
onEdit: (
resourceId: string,
thresholds: Record<string, number | undefined>,
@@ -159,7 +159,6 @@ export function AlertResourceTableRow(props: AlertResourceTableRowProps) {
value <= 0 ? 'Off' : props.formatMetricValue(metric, value);
const MetricValueWithHeat = (metricProps: {
- resourceId: string;
metric: string;
value: number;
isOverridden: boolean;
@@ -183,7 +182,7 @@ export function AlertResourceTableRow(props: AlertResourceTableRowProps) {
>
{displayText}
</span>
- <Show when={props.hasActiveAlert(metricProps.resourceId, metricProps.metric)}>
+ <Show when={props.hasActiveAlert(props.resource, metricProps.metric)}>
<div class="w-1.5 h-1.5 rounded-full bg-red-500 animate-pulse" title="Active alert" />
</Show>
</div>
@@ -450,7 +449,6 @@ export function AlertResourceTableRow(props: AlertResourceTableRowProps) {
aria-label={`Edit ${column} threshold for ${resourceLabel()}: ${metricValueText(metric, displayValue(metric))}`}
>
<MetricValueWithHeat
- resourceId={props.resource.id}
metric={metric}
value={displayValue(metric)}
isOverridden={isOverridden(metric)}
diff --git a/frontend-modern/src/components/Alerts/ResourceTable.test.tsx b/frontend-modern/src/components/Alerts/ResourceTable.test.tsx
index b0b2ab2638..b3e99317fb 100644
--- a/frontend-modern/src/components/Alerts/ResourceTable.test.tsx
+++ b/frontend-modern/src/components/Alerts/ResourceTable.test.tsx
@@ -844,17 +844,24 @@ describe('ResourceTable', () => {
});
it('shows active alert indicator dot when hasActiveAlert returns true', () => {
- const hasActiveAlert = vi.fn((_resourceId: string, metric: string) => metric === 'cpu');
- const props = makeProps({
- resources: [makeResource({ id: 'vm-1', thresholds: { cpu: 90, memory: 85 } })],
- hasActiveAlert,
+ const hasActiveAlert = vi.fn((_resource: unknown, metric: string) => metric === 'cpu');
+ const resource = makeResource({
+ id: 'vm-1',
+ alertResourceIds: ['vm-1', 'pve1-101'],
+ thresholds: { cpu: 90, memory: 85 },
});
+ const props = makeProps({ resources: [resource], hasActiveAlert });
render(() => <ResourceTable {...props} />);
// The active alert indicator is a pulsing red dot
- const alertDot = document.querySelector('[title="Active alert"]');
- expect(alertDot).toBeTruthy();
- expect(alertDot!.className).toContain('animate-pulse');
+ const alertDots = document.querySelectorAll('[title="Active alert"]');
+ expect(alertDots).toHaveLength(1);
+ expect(alertDots[0].className).toContain('animate-pulse');
+ // The row hands over the whole resource so its alert resource IDs reach the lookup.
+ expect(hasActiveAlert).toHaveBeenCalledWith(
+ expect.objectContaining({ id: 'vm-1', alertResourceIds: ['vm-1', 'pve1-101'] }),
+ 'cpu',
+ );
});
});
diff --git a/frontend-modern/src/components/Alerts/ResourceTable.tsx b/frontend-modern/src/components/Alerts/ResourceTable.tsx
index 4e70819580..f447357216 100644
--- a/frontend-modern/src/components/Alerts/ResourceTable.tsx
+++ b/frontend-modern/src/components/Alerts/ResourceTable.tsx
@@ -54,7 +54,7 @@ export interface ResourceTableProps {
editingThresholds: () => Record<string, number | undefined>;
setEditingThresholds: (value: Record<string, number | undefined>) => void;
formatMetricValue: (metric: string, value: number | undefined) => string;
- hasActiveAlert: (resourceId: string, metric: string) => boolean;
+ hasActiveAlert: (resource: Resource, metric: string) => boolean;
globalDefaults?: Record<string, number | undefined>;
/** Metrics whose unset global default follows another setting. */
globalDefaultFallbacks?: Record<string, AlertResourceGlobalDefaultFallback>;
diff --git a/frontend-modern/src/features/alerts/thresholds/__tests__/thresholdsActiveAlert.test.ts b/frontend-modern/src/features/alerts/thresholds/__tests__/thresholdsActiveAlert.test.ts
new file mode 100644
index 0000000000..a0ff8623f4
--- /dev/null
+++ b/frontend-modern/src/features/alerts/thresholds/__tests__/thresholdsActiveAlert.test.ts
@@ -0,0 +1,241 @@
+import { createRoot, createSignal } from 'solid-js';
+import { describe, expect, it } from 'vitest';
+
+import { agentSensorResourceId } from '@/features/alerts/agentSensorIdentity';
+import type { Alert } from '@/types/api';
+import type { Resource } from '@/types/resource';
+
+import { useThresholdsGuestData } from '../hooks/useThresholdsGuestData';
+import { useThresholdsHostData } from '../hooks/useThresholdsHostData';
+import type { Resource as TableResource } from '../tableTypes';
+import { indexActiveMetricAlerts, thresholdRowHasActiveAlert } from '../thresholdsResourceModel';
+import type { ThresholdsTableProps } from '../types';
+
+// Shapes follow a mock stack's live payloads: unified resource IDs on the
+// rows, poller and agent keys on the alerts.
+const node = {
+ id: 'node-6f1c2a9e4b7d3c10',
+ type: 'node',
+ name: 'pve1',
+ displayName: 'pve1',
+ status: 'online',
+ proxmox: { sourceId: 'mock-cluster-1-pve1' },
+ canonicalIdentity: { primaryId: 'node:mock-cluster-1-pve1' },
+} as unknown as Resource;
+
+// A Proxmox node running a Pulse agent arrives as one merged resource that
+// answers on the Proxmox and Machines tabs alike.
+const linkedNode = {
+ id: 'agent-3cd365581fe713ed',
+ type: 'agent',
+ name: 'West Production A',
+ displayName: 'West Production A',
+ status: 'online',
+ proxmox: { sourceId: 'mock-cluster-1-pve2' },
+ discoveryTarget: {
+ resourceType: 'agent',
+ agentId: 'host-node-mock-cluster-1-pve2',
+ resourceId: 'host-node-mock-cluster-1-pve2',
+ },
+ canonicalIdentity: {
+ primaryId: 'agent:host-node-mock-cluster-1-pve2',
+ aliases: ['agent:host-node-mock-cluster-1-pve2', 'host-node-mock-cluster-1-pve2'],
+ },
+ agent: { agentId: 'host-node-mock-cluster-1-pve2' },
+} as unknown as Resource;
+
+const machine = {
+ id: 'agent-acdfdee2953587fb',
+ type: 'agent',
+ name: 'Apollo-114',
+ displayName: 'Apollo-114',
+ status: 'online',
+ discoveryTarget: { resourceType: 'agent', agentId: 'host-linux-1', resourceId: 'host-linux-1' },
+ canonicalIdentity: { primaryId: 'agent:host-linux-1' },
+ agent: {
+ agentId: 'host-linux-1',
+ disks: [{ mountpoint: '/' }, { mountpoint: '/data' }],
+ sensors: {
+ native: [
+ {
+ id: 'coretemp-isa-0000/temp1',
+ chip: 'coretemp-isa-0000',
+ channel: 'temp1',
+ label: 'Package id 0',
+ kind: 'temperature',
+ unit: 'celsius',
+ value: 42.9,
+ status: 'ok',
+ },
+ ],
+ },
+ },
+} as unknown as Resource;
+
+const guest = {
+ id: 'vm-24bae4f81cb24f06',
+ type: 'vm',
+ name: 'analytics-batch-01',
+ status: 'running',
+ proxmox: {
+ sourceId: 'mock-cluster-1-pve1-109',
+ node: 'pve1',
+ instance: 'mock-cluster-1',
+ vmid: 109,
+ },
+} as unknown as Resource;
+
+const SENSOR_ID = 'coretemp-isa-0000/temp1';
+
+const metricAlert = (resourceId: string, metric: string): Alert =>
+ ({
+ id: `${resourceId}::metric-threshold:${metric}`,
+ type: metric,
+ level: 'critical',
+ resourceId,
+ resourceName: resourceId,
+ node: '',
+ instance: '',
+ message: '',
+ value: 99,
+ threshold: 1,
+ startTime: '2026-11-01T13:00:00Z',
+ acknowledged: false,
+ }) as Alert;
+
+// The live map, keyed by alert ID as the websocket store keeps it.
+const activeAlertMap = (...alerts: Alert[]): Record<string, Alert> =>
+ Object.fromEntries(alerts.map((alert) => [alert.id, alert]));
+
+const thresholdRows = () =>
+ createRoot((dispose) => {
+ const [term] = createSignal('');
+ const props = {
+ nodes: [node, linkedNode],
+ agents: [machine, linkedNode],
+ allGuests: () => [guest],
+ overrides: () => [],
+ nodeDefaults: {},
+ agentDefaults: {},
+ guestDefaults: {},
+ backupDefaults: () => ({}),
+ snapshotDefaults: () => ({}),
+ } as unknown as ThresholdsTableProps;
+ const host = useThresholdsHostData({ props, editingId: () => null, searchTerm: term });
+ const guests = useThresholdsGuestData({ props, editingId: () => null, searchTerm: term });
+ const rows = {
+ node: host.nodesWithOverrides()[0],
+ linkedNode: host.nodesWithOverrides()[1],
+ machine: host.agentsWithOverrides()[0],
+ linkedMachine: host.agentsWithOverrides()[1],
+ rootDisk: host.agentDisksWithOverrides().find((row) => row.name === '/'),
+ dataDisk: host.agentDisksWithOverrides().find((row) => row.name === '/data'),
+ sensor: host.agentSensorsWithOverrides()[0],
+ guest: Object.values(guests.guestsGroupedByNode()).flat()[0],
+ };
+ dispose();
+ return rows;
+ });
+
+const lit = (alerts: Record<string, Alert>, row: TableResource | undefined, metric: string) => {
+ expect(row).toBeDefined();
+ return thresholdRowHasActiveAlert(indexActiveMetricAlerts(alerts), row!, metric);
+};
+
+describe('threshold row active-alert dot', () => {
+ it('lights a node row from the alert raised on its Proxmox source ID', () => {
+ const rows = thresholdRows();
+ const alerts = activeAlertMap(metricAlert('mock-cluster-1-pve1', 'temperature'));
+
+ expect(lit(alerts, rows.node, 'temperature')).toBe(true);
+ expect(lit(alerts, rows.node, 'cpu')).toBe(false);
+ });
+
+ it("keeps a linked node's agent alerts on its Machines row", () => {
+ const rows = thresholdRows();
+ const alerts = activeAlertMap(
+ // CPU temperature stays with the node; CPU and disk move to the agent.
+ metricAlert('mock-cluster-1-pve2', 'temperature'),
+ metricAlert('agent:host-node-mock-cluster-1-pve2', 'cpu'),
+ metricAlert('agent:host-node-mock-cluster-1-pve2/disk:data', 'disk'),
+ );
+
+ expect(lit(alerts, rows.linkedNode, 'temperature')).toBe(true);
+ expect(lit(alerts, rows.linkedNode, 'cpu')).toBe(false);
+ expect(lit(alerts, rows.linkedNode, 'disk')).toBe(false);
+ expect(lit(alerts, rows.linkedMachine, 'cpu')).toBe(true);
+ expect(lit(alerts, rows.linkedMachine, 'disk')).toBe(true);
+ // A node CPU alert raised before the agent took over is judged by the node's limit.
+ expect(
+ lit(activeAlertMap(metricAlert('mock-cluster-1-pve2', 'cpu')), rows.linkedMachine, 'cpu'),
+ ).toBe(false);
+ });
+
+ it('lights a machine row from its "agent:<host>" alerts', () => {
+ const rows = thresholdRows();
+ const alerts = activeAlertMap(
+ metricAlert('agent:host-linux-1', 'cpu'),
+ metricAlert('agent:host-linux-1', 'memory'),
+ );
+
+ expect(rows.machine?.id).toBe('host-linux-1');
+ expect(lit(alerts, rows.machine, 'cpu')).toBe(true);
+ expect(lit(alerts, rows.machine, 'memory')).toBe(true);
+ expect(lit(alerts, rows.machine, 'disk')).toBe(false);
+ });
+
+ it('lights a machine disk row and the machine row whose Disk limits it inherits', () => {
+ const rows = thresholdRows();
+ const alerts = activeAlertMap(
+ metricAlert('agent:host-linux-1/disk:data', 'disk'),
+ metricAlert('agent:host-linux-1/disk_temp:sda', 'diskTemperature'),
+ );
+
+ expect(lit(alerts, rows.dataDisk, 'disk')).toBe(true);
+ expect(lit(alerts, rows.rootDisk, 'disk')).toBe(false);
+ expect(lit(alerts, rows.machine, 'disk')).toBe(true);
+ expect(lit(alerts, rows.machine, 'diskTemperature')).toBe(true);
+ expect(lit(alerts, rows.machine, 'cpu')).toBe(false);
+ });
+
+ it('lights a machine sensor row from its hex-keyed sensor alert only', () => {
+ const rows = thresholdRows();
+ const alerts = activeAlertMap(
+ metricAlert(agentSensorResourceId('host-linux-1', SENSOR_ID), 'temperature'),
+ );
+
+ expect(rows.sensor?.id).toBe(agentSensorResourceId('host-linux-1', SENSOR_ID));
+ expect(lit(alerts, rows.sensor, 'temperature')).toBe(true);
+ // A sensor's temperature is not one of the machine row's limits.
+ expect(lit(alerts, rows.machine, 'temperature')).toBe(false);
+ });
+
+ it('lights a guest row from the alert raised on its Proxmox source ID', () => {
+ const rows = thresholdRows();
+ const alerts = activeAlertMap(metricAlert('mock-cluster-1-pve1-109', 'cpu'));
+
+ expect(lit(alerts, rows.guest, 'cpu')).toBe(true);
+ expect(lit(alerts, rows.guest, 'memory')).toBe(false);
+ });
+
+ it('matches nested alerts only for machine rows', () => {
+ const index = indexActiveMetricAlerts(
+ activeAlertMap(metricAlert('agent:host-linux-1/disk:data', 'disk')),
+ );
+ const row = { id: 'host-linux-1', alertResourceIds: ['agent:host-linux-1'] };
+
+ expect(thresholdRowHasActiveAlert(index, { ...row, type: 'agent' }, 'disk')).toBe(true);
+ expect(thresholdRowHasActiveAlert(index, { ...row, type: 'dockerHost' }, 'disk')).toBe(false);
+ });
+
+ it('falls back to the row ID when a row names no alert resource IDs', () => {
+ const index = indexActiveMetricAlerts(
+ activeAlertMap(metricAlert('storage-d5aa7911eea57351', 'usage')),
+ );
+
+ expect(thresholdRowHasActiveAlert(index, { id: 'storage-d5aa7911eea57351' }, 'usage')).toBe(
+ true,
+ );
+ expect(indexActiveMetricAlerts(undefined).byResource.size).toBe(0);
+ });
+});
diff --git a/frontend-modern/src/features/alerts/thresholds/hooks/__tests__/useThresholdsTableState.branchcov0725am.test.tsx b/frontend-modern/src/features/alerts/thresholds/hooks/__tests__/useThresholdsTableState.branchcov0725am.test.tsx
index 406b666be5..3cbcc8c8bb 100644
--- a/frontend-modern/src/features/alerts/thresholds/hooks/__tests__/useThresholdsTableState.branchcov0725am.test.tsx
+++ b/frontend-modern/src/features/alerts/thresholds/hooks/__tests__/useThresholdsTableState.branchcov0725am.test.tsx
@@ -294,14 +294,22 @@ describe('useThresholdsTableState — branch coverage', () => {
});
describe('hasActiveAlert', () => {
+ const cpuAlert = {
+ id: 'node-1::metric-threshold:cpu',
+ type: 'cpu',
+ resourceId: 'node-1',
+ };
+
it('returns false up-front when alert detection is disabled', () => {
mockAlertsEnabled = false;
const props = buildProps();
- props.activeAlerts = { 'r-cpu': {} } as unknown as ThresholdsTableProps['activeAlerts'];
+ props.activeAlerts = {
+ [cpuAlert.id]: cpuAlert,
+ } as unknown as ThresholdsTableProps['activeAlerts'];
const captured = mount(props);
// Detection gate short-circuits before the lookup even happens.
- expect(captured.hasActiveAlert('r', 'cpu')).toBe(false);
+ expect(captured.hasActiveAlert({ id: 'node-1', name: 'node-1' }, 'cpu')).toBe(false);
});
it('returns false when no activeAlerts map is supplied', () => {
@@ -309,19 +317,25 @@ describe('useThresholdsTableState — branch coverage', () => {
// activeAlerts intentionally left undefined.
const captured = mount(props);
- expect(captured.hasActiveAlert('r', 'cpu')).toBe(false);
+ expect(captured.hasActiveAlert({ id: 'node-1', name: 'node-1' }, 'cpu')).toBe(false);
});
- it('distinguishes present vs absent "<id>-<metric>" keys when enabled', () => {
+ it('matches alerts on their resourceId and type, not their map key', () => {
const props = buildProps();
props.activeAlerts = {
- 'node-1-cpu': { id: 'x' },
+ [cpuAlert.id]: cpuAlert,
} as unknown as ThresholdsTableProps['activeAlerts'];
const captured = mount(props);
- expect(captured.hasActiveAlert('node-1', 'cpu')).toBe(true);
- expect(captured.hasActiveAlert('node-1', 'memory')).toBe(false);
- expect(captured.hasActiveAlert('node-9', 'cpu')).toBe(false);
+ expect(captured.hasActiveAlert({ id: 'node-1', name: 'node-1' }, 'cpu')).toBe(true);
+ expect(captured.hasActiveAlert({ id: 'node-1', name: 'node-1' }, 'memory')).toBe(false);
+ expect(captured.hasActiveAlert({ id: 'node-9', name: 'node-9' }, 'cpu')).toBe(false);
+ expect(
+ captured.hasActiveAlert(
+ { id: 'node-unified', name: 'node-1', alertResourceIds: ['node-unified', 'node-1'] },
+ 'cpu',
+ ),
+ ).toBe(true);
});
});
diff --git a/frontend-modern/src/features/alerts/thresholds/hooks/useThresholdsGuestData.ts b/frontend-modern/src/features/alerts/thresholds/hooks/useThresholdsGuestData.ts
index 14c0d52e5f..2d2eb0f19a 100644
--- a/frontend-modern/src/features/alerts/thresholds/hooks/useThresholdsGuestData.ts
+++ b/frontend-modern/src/features/alerts/thresholds/hooks/useThresholdsGuestData.ts
@@ -9,6 +9,7 @@ import {
} from '@/features/alerts/guestOverrideIdentity';
import { getAlertResourceDisplayLabel } from '@/features/alerts/helpers';
import type { Disk } from '@/types/api';
+import { getUnifiedResourceAlertResourceIds } from '@/utils/alerts';
import { hasPulseRelaxedGuestTag } from '@/utils/metricThresholds';
import { resolveResourcePlatformType } from '@/utils/sourcePlatforms';
import { getWorkloadGuestDiskRead } from '@/utils/workloadGuestPresentation';
@@ -56,6 +57,7 @@ export function useThresholdsGuestData(inputs: ThresholdsDataInputs) {
return {
id: guest.id,
+ alertResourceIds: getUnifiedResourceAlertResourceIds(guest),
name: getAlertResourceDisplayLabel(guest),
displayName: getAlertResourceDisplayLabel(guest),
rawName: guest.name,
diff --git a/frontend-modern/src/features/alerts/thresholds/hooks/useThresholdsHostData.ts b/frontend-modern/src/features/alerts/thresholds/hooks/useThresholdsHostData.ts
index 24f6d5696a..f276bbfdd8 100644
--- a/frontend-modern/src/features/alerts/thresholds/hooks/useThresholdsHostData.ts
+++ b/frontend-modern/src/features/alerts/thresholds/hooks/useThresholdsHostData.ts
@@ -10,6 +10,7 @@ import { formatTemperature } from '@/utils/temperature';
import type { GroupHeaderMeta, Resource as TableResource } from '../tableTypes';
import { ThresholdsDataInputs } from '../thresholdsResourceModel';
import {
+ agentAlertResourceId,
agentDiskResourceId,
buildAgentHeaderMeta,
createOverridesMap,
@@ -22,6 +23,7 @@ import {
platformData,
readRecord,
readString,
+ uniqueIds,
} from '../thresholdsResourceModel';
export function useThresholdsHostData(inputs: ThresholdsDataInputs) {
@@ -65,6 +67,10 @@ export function useThresholdsHostData(inputs: ThresholdsDataInputs) {
return {
id: node.id,
+ // The node's own alerts are raised on its Proxmox node ID. A node merged
+ // with its Pulse agent hands CPU, memory and disk to the agent, whose
+ // alerts its Machines row shows against the agent's limits.
+ alertResourceIds: uniqueIds(node.proxmox?.sourceId, node.id),
name: sanitizedName,
displayName: sanitizedName,
rawName: originalDisplayName,
@@ -115,6 +121,11 @@ export function useThresholdsHostData(inputs: ThresholdsDataInputs) {
return {
id: resourceId,
+ alertResourceIds: [
+ agentAlertResourceId(
+ readString(agentResource.agent?.agentId) || hostActionId(agentResource),
+ ),
+ ],
name: displayName,
displayName,
rawName: agentResource.identity?.hostname ?? agentResource.name,
diff --git a/frontend-modern/src/features/alerts/thresholds/hooks/useThresholdsTableState.ts b/frontend-modern/src/features/alerts/thresholds/hooks/useThresholdsTableState.ts
index aa00583bd3..1a75bc65bb 100644
--- a/frontend-modern/src/features/alerts/thresholds/hooks/useThresholdsTableState.ts
+++ b/frontend-modern/src/features/alerts/thresholds/hooks/useThresholdsTableState.ts
@@ -42,6 +42,10 @@ import {
} from '@/utils/alertThresholdsPresentation';
import { PMG_THRESHOLD_COLUMNS } from '@/features/alerts/thresholds/constants';
import { normalizeDockerIgnoredInput } from '@/features/alerts/thresholds/helpers';
+import {
+ indexActiveMetricAlerts,
+ thresholdRowHasActiveAlert,
+} from '@/features/alerts/thresholds/thresholdsResourceModel';
import type { ThresholdsTableProps } from '@/features/alerts/thresholds/types';
import type {
Resource as TableResource,
@@ -268,10 +272,11 @@ export function useThresholdsTableState(props: ThresholdsTableProps) {
props.setHasUnsavedChanges(true);
};
- const hasActiveAlert = (resourceId: string, metric: string): boolean => {
+ const activeMetricAlerts = createMemo(() => indexActiveMetricAlerts(props.activeAlerts));
+
+ const hasActiveAlert = (resource: TableResource, metric: string): boolean => {
if (!alertsEnabled()) return false;
- if (!props.activeAlerts) return false;
- return `${resourceId}-${metric}` in props.activeAlerts;
+ return thresholdRowHasActiveAlert(activeMetricAlerts(), resource, metric);
};
const {
diff --git a/frontend-modern/src/features/alerts/thresholds/tableTypes.ts b/frontend-modern/src/features/alerts/thresholds/tableTypes.ts
index a290d98671..18f9aa9c0f 100644
--- a/frontend-modern/src/features/alerts/thresholds/tableTypes.ts
+++ b/frontend-modern/src/features/alerts/thresholds/tableTypes.ts
@@ -9,6 +9,8 @@ export interface Resource {
id: string;
overrideIdCandidates?: string[];
overrideStorageId?: string;
+ /** Resource IDs this row's alerts are raised on (getUnifiedResourceAlertResourceIds); `id` when unset. */
+ alertResourceIds?: string[];
name: string;
displayName?: string;
policy?: ResourcePolicy;
diff --git a/frontend-modern/src/features/alerts/thresholds/thresholdsResourceModel.ts b/frontend-modern/src/features/alerts/thresholds/thresholdsResourceModel.ts
index d44b7558da..227442bef3 100644
--- a/frontend-modern/src/features/alerts/thresholds/thresholdsResourceModel.ts
+++ b/frontend-modern/src/features/alerts/thresholds/thresholdsResourceModel.ts
@@ -8,7 +8,8 @@ import {
} from '@/utils/discoveryTarget';
import { getAlertResourceDisplayLabel } from '@/features/alerts/helpers';
-import type { GroupHeaderMeta } from './tableTypes';
+import type { Alert } from '@/types/api';
+import type { GroupHeaderMeta, Resource as TableResource } from './tableTypes';
import type { Override, ThresholdsTableProps } from './types';
export interface ThresholdsDataInputs {
@@ -240,6 +241,68 @@ export const agentDiskResourceId = (
return `agent:${agentId}/disk:${label}`;
};
+// The resource ID a machine's own alerts are raised on (internal/alerts host.go
+// hostResourceID). Its threshold row and override are keyed on the bare host ID.
+export const agentAlertResourceId = (hostId: string): string => {
+ const trimmed = hostId.trim();
+ if (trimmed.startsWith('agent:')) return trimmed;
+ return `agent:${trimmed || 'unknown'}`;
+};
+
+export interface ActiveMetricAlertIndex {
+ /** Metrics with an open alert, by the resource ID the alert was raised on. */
+ byResource: Map<string, Set<string>>;
+ /** Metrics with an open alert on a machine's disks, by the machine's "agent:<host>" key. */
+ byMachine: Map<string, Set<string>>;
+}
+
+const addIndexedMetric = (index: Map<string, Set<string>>, key: string, metric: string) => {
+ const metrics = index.get(key);
+ if (metrics) metrics.add(metric);
+ else index.set(key, new Set([metric]));
+};
+
+// The live alert map is keyed by alert ID ("<resource>::metric-threshold:<metric>"
+// for threshold alerts), which a row cannot rebuild. Rows match on the fields
+// each alert carries instead: the resource it was raised on and its metric type.
+export const indexActiveMetricAlerts = (
+ activeAlerts: Record<string, Alert> | undefined,
+): ActiveMetricAlertIndex => {
+ const byResource = new Map<string, Set<string>>();
+ const byMachine = new Map<string, Set<string>>();
+ Object.values(activeAlerts ?? {}).forEach((alert) => {
+ const resourceId = alert?.resourceId?.trim();
+ const metric = alert?.type?.trim();
+ if (!resourceId || !metric) return;
+ addIndexedMetric(byResource, resourceId, metric);
+ // "agent:<host>/disk:<mount>", "agent:<host>/disk_temp:<device>". Other
+ // children (sensors, RAID arrays) have limits of their own.
+ const childSeparator = resourceId.indexOf('/');
+ if (!resourceId.startsWith('agent:') || childSeparator < 0) return;
+ const child = resourceId.slice(childSeparator + 1);
+ if (child.startsWith('disk:') || child.startsWith('disk_temp:')) {
+ addIndexedMetric(byMachine, resourceId.slice(0, childSeparator), metric);
+ }
+ });
+ return { byResource, byMachine };
+};
+
+// Whether a threshold row has an open alert on one of its metrics. A machine
+// row's Disk % and Disk Temp limits are what its disks' alerts judge, and
+// those alerts are raised on the disks, so a machine row also answers for them.
+export const thresholdRowHasActiveAlert = (
+ index: ActiveMetricAlertIndex,
+ row: Pick<TableResource, 'id' | 'alertResourceIds' | 'type'>,
+ metric: string,
+): boolean => {
+ const alertResourceIds = row.alertResourceIds?.length ? row.alertResourceIds : [row.id];
+ return alertResourceIds.some(
+ (alertResourceId) =>
+ index.byResource.get(alertResourceId)?.has(metric) ||
+ (row.type === 'agent' && index.byMachine.get(alertResourceId)?.has(metric)),
+ );
+};
+
export const storageCoords = (resource: Resource): { node: string; instance: string } => {
const data = platformData(resource);
if (resource.type === 'datastore') {
diff --git a/frontend-modern/src/utils/__tests__/alerts.test.ts b/frontend-modern/src/utils/__tests__/alerts.test.ts
index 61c687015a..ad9ffadc6c 100644
--- a/frontend-modern/src/utils/__tests__/alerts.test.ts
+++ b/frontend-modern/src/utils/__tests__/alerts.test.ts
@@ -3,6 +3,7 @@ import {
getAlertsForResource,
getAlertsForUnifiedResource,
getOwnAlertsForUnifiedResource,
+ getUnifiedResourceAlertResourceIds,
getAlertStyles,
getUnifiedResourceAlertStyles,
} from '@/utils/alerts';
@@ -241,6 +242,26 @@ describe('alerts module surface', () => {
});
});
+describe('getUnifiedResourceAlertResourceIds', () => {
+ it("lists the exact keys a Proxmox guest's own alerts are raised on", () => {
+ // Shape from a mock-mode /api/resources payload: the row carries the
+ // unified id, the guest's threshold alerts its Proxmox source id.
+ const guest = {
+ id: 'vm-24bae4f81cb24f06',
+ type: 'vm',
+ name: 'analytics-batch-01',
+ proxmox: { sourceId: 'mock-cluster-1-pve1-109' },
+ canonicalIdentity: { primaryId: 'vm:mock-cluster-1-pve1-109' },
+ } as unknown as Resource;
+
+ expect(getUnifiedResourceAlertResourceIds(guest)).toEqual([
+ 'vm-24bae4f81cb24f06',
+ 'vm:mock-cluster-1-pve1-109',
+ 'mock-cluster-1-pve1-109',
+ ]);
+ });
+});
+
describe('getAlertsForUnifiedResource', () => {
// Identity shapes below are copied from a mock-mode /api/state payload.
const alert = (id: string, resourceId: string, overrides: Partial<Alert> = {}): Alert => ({
diff --git a/frontend-modern/src/utils/alerts.ts b/frontend-modern/src/utils/alerts.ts
index 6cb2104849..0c6326cb9a 100644
--- a/frontend-modern/src/utils/alerts.ts
+++ b/frontend-modern/src/utils/alerts.ts
@@ -232,6 +232,15 @@ const getUnifiedResourceAlertKeys = (
return { exact, machine: [...machine] };
};
+/**
+ * The resource IDs a unified resource's own alerts are raised on: its unified
+ * id, the poller's source or metrics-target id, and a machine's "agent:<id>"
+ * and "docker:<id>" keys. Alerts on its components nest under the latter.
+ */
+export const getUnifiedResourceAlertResourceIds = (resource: Resource): string[] => [
+ ...getUnifiedResourceAlertKeys(resource).exact,
+];
+
/**
* Open alerts for one unified resource, read from the websocket's active
* alert map, most severe first. This is the canonical source for a resource