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.

Support guest filesystem alert overrides (#1205)

[email protected]110ed3eb2b02
diff --git a/docs/release-control/v6/internal/subsystems/alerts.md b/docs/release-control/v6/internal/subsystems/alerts.md
index 232a77fc2b..5a282fe384 100644
--- a/docs/release-control/v6/internal/subsystems/alerts.md
+++ b/docs/release-control/v6/internal/subsystems/alerts.md
@@ -84,6 +84,18 @@ the one whose identity alerting honours. Standalone Pulse-agent machines belong
to Machines, so the Virtualization Hosts section is fed by provider-owned
virtualization nodes rather than by every resource of type `agent`.
+QEMU guest-agent filesystems have their own threshold identity:
+`guest-disk:<stable-guest-key>/disk:<mount-device-key>`. The stable guest key
+must use the same cluster-aware alias chain as guest thresholds so a VM node
+move does not strand its filesystem settings. A filesystem override may disable
+that mount or supply its own disk threshold. Once a mount has a dedicated
+override, it is evaluated only against that override and is excluded from the
+guest aggregate disk alert; otherwise the aggregate would still fire at the
+guest default and silently defeat a disabled or relaxed mount. The visible
+threshold row keeps the live `guestID-disk-*` alert resource identity for
+active-state and intent-policy linkage while persisting through the stable
+`guest-disk:*` override identity.
+
A per-metric threshold is off whenever its trigger is `<= 0`. That boundary is
engine truth (`internal/alerts/canonical_metric.go`,
`internal/alerts/config_runtime.go`), not a display convention: `-1` is the
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
index 693a5dc3ce..0b90b36e19 100644
--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md
+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
@@ -4677,6 +4677,13 @@ using the shared contract in
Future infrastructure-thresholds presentation changes should extend those section
surfaces rather than restoring mixed JSX ownership to
`frontend-modern/src/components/Alerts/ThresholdsTableProxmoxTab.tsx`.
+The Proxmox threshold tab includes a separate Guest Filesystems section for
+QEMU guest-agent mounts. Rows use the live per-filesystem alert resource ID for
+status and delay actions, but carry explicit override candidates and a stable
+override storage ID into the shared mutation owners. This split is required:
+using the alert ID as the persistence key strands settings on VM node moves,
+while using only the persistence ID breaks active-alert and intent-policy
+linkage in the shared resource table.
The Docker tab now follows that same composition pattern through
`frontend-modern/src/components/Alerts/ThresholdsTableDockerIgnoredPrefixesSection.tsx`,
`frontend-modern/src/components/Alerts/ThresholdsTableDockerServiceGapSection.tsx`,
diff --git a/frontend-modern/src/components/Alerts/ThresholdsTableProxmoxGuestDisksSection.tsx b/frontend-modern/src/components/Alerts/ThresholdsTableProxmoxGuestDisksSection.tsx
new file mode 100644
index 0000000000..f21488c6f7
--- /dev/null
+++ b/frontend-modern/src/components/Alerts/ThresholdsTableProxmoxGuestDisksSection.tsx
@@ -0,0 +1,61 @@
+import { Show } from 'solid-js';
+import HardDrive from 'lucide-solid/icons/hard-drive';
+
+import { ResourceTable } from './ResourceTable';
+import { CollapsibleSection } from './Thresholds/sections/CollapsibleSection';
+import { formatMetricValue } from '@/features/alerts/thresholds/helpers';
+import type { ThresholdsTableSectionProps } from '@/features/alerts/thresholds/thresholdsTableSectionProps';
+
+export function ThresholdsTableProxmoxGuestDisksSection(props: ThresholdsTableSectionProps) {
+ const { state, tableProps } = props;
+
+ return (
+ <Show when={state.hasSection('guestDisks')}>
+ <CollapsibleSection
+ id="guestDisks"
+ title={state.sectionTitles.guestDisks}
+ resourceCount={state.guestDisksWithOverrides().length}
+ collapsed={state.isCollapsed('guestDisks')}
+ onToggle={() => state.toggleSection('guestDisks')}
+ icon={<HardDrive class="w-5 h-5" />}
+ isGloballyDisabled={tableProps.disableAllGuests()}
+ emptyMessage={state.GUEST_DISKS_EMPTY_STATE}
+ >
+ <div ref={state.registerSection('guestDisks')} class="scroll-mt-24">
+ <ResourceTable
+ title=""
+ onConfigureResourceIntent={tableProps.onConfigureResourceIntent}
+ groupedResources={state.guestDisksGroupedByGuest()}
+ columns={['Disk %']}
+ activeAlerts={tableProps.activeAlerts}
+ emptyMessage={state.GUEST_DISKS_FILTER_EMPTY_STATE}
+ onEdit={state.startEditing}
+ onSaveEdit={state.saveEdit}
+ onCancelEdit={state.cancelEdit}
+ onRemoveOverride={state.removeOverride}
+ onToggleDisabled={state.toggleDisabled}
+ showOfflineAlertsColumn={false}
+ editingId={state.editingId}
+ editingThresholds={state.editingThresholds}
+ setEditingThresholds={state.setEditingThresholds}
+ editingNote={state.editingNote}
+ setEditingNote={state.setEditingNote}
+ onBulkEdit={(ids) => state.handleBulkEdit(ids, ['Disk %'])}
+ formatMetricValue={formatMetricValue}
+ hasActiveAlert={state.hasActiveAlert}
+ globalDefaults={{ disk: tableProps.guestDefaults.disk }}
+ setGlobalDefaults={(value) => {
+ if (typeof value === 'function') {
+ const nextValue = value({ disk: tableProps.guestDefaults.disk });
+ tableProps.setGuestDefaults((prev) => ({ ...prev, disk: nextValue.disk }));
+ } else {
+ tableProps.setGuestDefaults((prev) => ({ ...prev, disk: value.disk }));
+ }
+ }}
+ setHasUnsavedChanges={tableProps.setHasUnsavedChanges}
+ />
+ </div>
+ </CollapsibleSection>
+ </Show>
+ );
+}
diff --git a/frontend-modern/src/components/Alerts/ThresholdsTableProxmoxTab.tsx b/frontend-modern/src/components/Alerts/ThresholdsTableProxmoxTab.tsx
index 48019a1498..c3dfcf24aa 100644
--- a/frontend-modern/src/components/Alerts/ThresholdsTableProxmoxTab.tsx
+++ b/frontend-modern/src/components/Alerts/ThresholdsTableProxmoxTab.tsx
@@ -1,5 +1,6 @@
import { ThresholdsTableProxmoxBackupsSection } from './ThresholdsTableProxmoxBackupsSection';
import { ThresholdsTableProxmoxGuestFilteringSection } from './ThresholdsTableProxmoxGuestFilteringSection';
+import { ThresholdsTableProxmoxGuestDisksSection } from './ThresholdsTableProxmoxGuestDisksSection';
import { ThresholdsTableProxmoxGuestsSection } from './ThresholdsTableProxmoxGuestsSection';
import { ThresholdsTableProxmoxNodesSection } from './ThresholdsTableProxmoxNodesSection';
import { ThresholdsTableProxmoxPBSSection } from './ThresholdsTableProxmoxPBSSection';
@@ -13,6 +14,7 @@ export function ThresholdsTableProxmoxTab(props: ThresholdsTableSectionProps) {
<>
<ThresholdsTableProxmoxNodesSection {...props} />
<ThresholdsTableProxmoxGuestsSection {...props} />
+ <ThresholdsTableProxmoxGuestDisksSection {...props} />
<ThresholdsTableProxmoxGuestFilteringSection {...props} />
<ThresholdsTableProxmoxBackupsSection {...props} />
<ThresholdsTableProxmoxSnapshotsSection {...props} />
diff --git a/frontend-modern/src/features/alerts/__tests__/guestOverrideIdentity.test.ts b/frontend-modern/src/features/alerts/__tests__/guestOverrideIdentity.test.ts
index 02906853e1..ee92267462 100644
--- a/frontend-modern/src/features/alerts/__tests__/guestOverrideIdentity.test.ts
+++ b/frontend-modern/src/features/alerts/__tests__/guestOverrideIdentity.test.ts
@@ -2,9 +2,13 @@ import { describe, expect, it } from 'vitest';
import {
getGuestOverrideIdentity,
+ guestDiskAlertResourceId,
+ guestDiskOverrideIdCandidates,
+ guestDiskOverrideStorageId,
guestOverrideIdCandidates,
guestOverrideStorageId,
normalizeGuestOverrideKey,
+ parseGuestDiskOverrideId,
} from '../guestOverrideIdentity';
describe('guestOverrideIdentity', () => {
@@ -289,4 +293,50 @@ describe('guestOverrideIdentity', () => {
expect(normalizeGuestOverrideKey(stable)).toBe(stable);
});
});
+
+ describe('guest filesystem override identity', () => {
+ const guest = {
+ id: 'cluster-a:node-1:100',
+ instance: 'cluster-a',
+ node: 'node-1',
+ vmid: 100,
+ };
+
+ it('uses the stable guest identity and the mount plus device', () => {
+ expect(guestDiskOverrideStorageId(guest, '/boot', '/dev/vda1')).toBe(
+ 'guest-disk:guest:cluster-a:100/disk:boot-dev-vda1',
+ );
+ expect(guestDiskAlertResourceId(guest, '/boot', '/dev/vda1')).toBe(
+ 'cluster-a:node-1:100-disk-boot-dev-vda1',
+ );
+ });
+
+ it('retains aliases so existing overrides survive node moves', () => {
+ expect(guestDiskOverrideIdCandidates(guest, '/boot', '/dev/vda1')).toEqual([
+ 'guest-disk:guest:cluster-a:100/disk:boot-dev-vda1',
+ 'guest-disk:cluster-a:node-1:100/disk:boot-dev-vda1',
+ 'guest-disk:cluster-a-100/disk:boot-dev-vda1',
+ 'guest-disk:cluster-a-node-1-100/disk:boot-dev-vda1',
+ ]);
+ });
+
+ it('normalizes root and Windows mount labels consistently', () => {
+ expect(guestDiskOverrideStorageId(guest, '/', undefined)).toBe(
+ 'guest-disk:guest:cluster-a:100/disk:root',
+ );
+ expect(guestDiskOverrideStorageId(guest, 'C:\\', undefined)).toBe(
+ 'guest-disk:guest:cluster-a:100/disk:c',
+ );
+ });
+
+ it('parses persisted filesystem override ids', () => {
+ expect(parseGuestDiskOverrideId('guest-disk:guest:cluster-a:100/disk:boot-dev-vda1')).toEqual(
+ {
+ guestKey: 'guest:cluster-a:100',
+ diskKey: 'boot-dev-vda1',
+ },
+ );
+ expect(parseGuestDiskOverrideId('guest:cluster-a:100')).toBeUndefined();
+ });
+ });
});
diff --git a/frontend-modern/src/features/alerts/alertOverridesModel.ts b/frontend-modern/src/features/alerts/alertOverridesModel.ts
index 8cc9fc0261..2f33d098ca 100644
--- a/frontend-modern/src/features/alerts/alertOverridesModel.ts
+++ b/frontend-modern/src/features/alerts/alertOverridesModel.ts
@@ -12,6 +12,7 @@ import {
} from './helpers';
import {
getGuestOverrideIdentity,
+ parseGuestDiskOverrideId,
guestOverrideIdCandidates,
guestOverrideStorageId,
normalizeGuestOverrideKey,
@@ -440,6 +441,23 @@ export const buildProjectedOverrides = ({
});
Object.entries(rawConfig).forEach(([key, thresholds]) => {
+ const guestDiskIdentity = parseGuestDiskOverrideId(key);
+ if (guestDiskIdentity) {
+ const guest = guestMap.get(guestDiskIdentity.guestKey);
+ const diskName = guestDiskIdentity.diskKey === 'root' ? '/' : guestDiskIdentity.diskKey;
+ upsertProjectedOverride({
+ id: key,
+ name: diskName,
+ type: 'guestDisk',
+ resourceType: 'Guest Filesystem',
+ node: guest ? getAlertResourceDisplayLabel(guest) : guestDiskIdentity.guestKey,
+ instance: guestDiskIdentity.guestKey,
+ disabled: thresholds.disabled || false,
+ thresholds: extractTriggerValues(thresholds),
+ });
+ return;
+ }
+
const alertPlatformResource = alertPlatformMap.get(key);
if (alertPlatformResource) {
const { resource, type, resourceType } = alertPlatformResource;
diff --git a/frontend-modern/src/features/alerts/guestOverrideIdentity.ts b/frontend-modern/src/features/alerts/guestOverrideIdentity.ts
index 043f953639..434d4342a7 100644
--- a/frontend-modern/src/features/alerts/guestOverrideIdentity.ts
+++ b/frontend-modern/src/features/alerts/guestOverrideIdentity.ts
@@ -165,3 +165,70 @@ export const normalizeGuestOverrideKey = (key: string): string => {
}
return stableGuestOverrideKey(parsed.instance, parsed.vmid);
};
+
+const sanitizeGuestDiskKey = (value: string): string => {
+ const trimmed = value.trim();
+ if (!trimmed) return '';
+ if (trimmed === '/') return 'root';
+
+ const withoutOuterSlashes = trimmed.replace(/^[/\\\s]+|[/\\\s]+$/g, '') || 'root';
+ return (
+ withoutOuterSlashes
+ .toLowerCase()
+ .replace(/[^a-z0-9.]+/g, '-')
+ .replace(/^-+|-+$/g, '')
+ .replace(/^\.+|\.+$/g, '') || 'disk'
+ );
+};
+
+const guestDiskKeySource = (mountpoint?: string, device?: string): string => {
+ const label = mountpoint?.trim() || device?.trim() || 'disk';
+ const normalizedDevice = device?.trim() || '';
+ return normalizedDevice && normalizedDevice.toLowerCase() !== label.toLowerCase()
+ ? `${label}-${normalizedDevice}`
+ : label;
+};
+
+const guestDiskOverrideId = (guestKey: string, diskKey: string): string =>
+ guestKey && diskKey ? `guest-disk:${guestKey}/disk:${diskKey}` : '';
+
+export const guestDiskOverrideStorageId = (
+ resource: GuestOverrideResourceLike,
+ mountpoint?: string,
+ device?: string,
+): string =>
+ guestDiskOverrideId(
+ guestOverrideStorageId(resource),
+ sanitizeGuestDiskKey(guestDiskKeySource(mountpoint, device)),
+ );
+
+export const guestDiskAlertResourceId = (
+ resource: GuestOverrideResourceLike,
+ mountpoint?: string,
+ device?: string,
+): string => {
+ const resourceId = asString(resource.id);
+ const diskKey = sanitizeGuestDiskKey(guestDiskKeySource(mountpoint, device));
+ return resourceId && diskKey ? `${resourceId}-disk-${diskKey}` : '';
+};
+
+export const guestDiskOverrideIdCandidates = (
+ resource: GuestOverrideResourceLike,
+ mountpoint?: string,
+ device?: string,
+): string[] => {
+ const diskKey = sanitizeGuestDiskKey(guestDiskKeySource(mountpoint, device));
+ return uniqueIds(
+ ...guestOverrideIdCandidates(resource).map((guestKey) =>
+ guestDiskOverrideId(guestKey, diskKey),
+ ),
+ );
+};
+
+export const parseGuestDiskOverrideId = (
+ key: string,
+): { guestKey: string; diskKey: string } | undefined => {
+ const match = key.trim().match(/^guest-disk:(.+)\/disk:([^/]+)$/);
+ if (!match?.[1] || !match[2]) return undefined;
+ return { guestKey: match[1], diskKey: match[2] };
+};
diff --git a/frontend-modern/src/features/alerts/thresholds/hooks/__tests__/useThresholdsAvailabilityMutations.test.tsx b/frontend-modern/src/features/alerts/thresholds/hooks/__tests__/useThresholdsAvailabilityMutations.test.tsx
index 05666b89d2..9b63c9f941 100644
--- a/frontend-modern/src/features/alerts/thresholds/hooks/__tests__/useThresholdsAvailabilityMutations.test.tsx
+++ b/frontend-modern/src/features/alerts/thresholds/hooks/__tests__/useThresholdsAvailabilityMutations.test.tsx
@@ -84,4 +84,64 @@ describe('useThresholdsAvailabilityMutations', () => {
expect(setHasUnsavedChanges).toHaveBeenCalledWith(true);
expect(removeAlerts).not.toHaveBeenCalled();
});
+
+ it('persists guest filesystem disables under the stable override identity', () => {
+ const overrideSignal = createSignal<any[]>([]);
+ const { props, rawOverridesConfig, removeAlerts } = buildTableProps(overrideSignal);
+ const filesystemResource: TableResource = {
+ id: 'cluster-a:node-2:100-disk-boot-dev-vda1',
+ overrideIdCandidates: [
+ 'guest-disk:guest:cluster-a:100/disk:boot-dev-vda1',
+ 'guest-disk:cluster-a:node-2:100/disk:boot-dev-vda1',
+ ],
+ overrideStorageId: 'guest-disk:guest:cluster-a:100/disk:boot-dev-vda1',
+ name: '/boot',
+ type: 'guestDisk',
+ resourceType: 'Guest Filesystem',
+ thresholds: {},
+ };
+
+ const { result } = renderHook(() =>
+ useThresholdsAvailabilityMutations({
+ props,
+ resources: {
+ nodesWithOverrides: () => [],
+ agentsWithOverrides: () => [],
+ agentDisksWithOverrides: () => [],
+ guestDisksWithOverrides: () => [filesystemResource],
+ dockerHostsWithOverrides: () => [],
+ guestsFlat: () => [],
+ dockerContainersFlat: () => [],
+ pbsServersWithOverrides: () => [],
+ storageWithOverrides: () => [],
+ },
+ removeOverride: vi.fn(),
+ }),
+ );
+
+ result.toggleDisabled(filesystemResource.id, true);
+
+ expect(overrideSignal[0]()).toEqual([
+ expect.objectContaining({
+ id: 'guest-disk:guest:cluster-a:100/disk:boot-dev-vda1',
+ disabled: true,
+ type: 'guestDisk',
+ }),
+ ]);
+ expect(rawOverridesConfig()).toEqual({
+ 'guest-disk:guest:cluster-a:100/disk:boot-dev-vda1': {
+ disabled: true,
+ },
+ });
+
+ const removePredicate = removeAlerts.mock.calls[0]?.[0] as
+ ((alert: { resourceId: string; type: string }) => boolean) | undefined;
+ expect(removePredicate).toBeTypeOf('function');
+ expect(
+ removePredicate?.({
+ resourceId: filesystemResource.id,
+ type: 'disk',
+ }),
+ ).toBe(true);
+ });
});
diff --git a/frontend-modern/src/features/alerts/thresholds/hooks/__tests__/useThresholdsGuestData.test.ts b/frontend-modern/src/features/alerts/thresholds/hooks/__tests__/useThresholdsGuestData.test.ts
new file mode 100644
index 0000000000..013c1dcb8b
--- /dev/null
+++ b/frontend-modern/src/features/alerts/thresholds/hooks/__tests__/useThresholdsGuestData.test.ts
@@ -0,0 +1,112 @@
+import { createRoot } from 'solid-js';
+import { describe, expect, it } from 'vitest';
+
+import type { ThresholdsTableProps } from '../../types';
+import { useThresholdsGuestData } from '../useThresholdsGuestData';
+
+describe('useThresholdsGuestData guest filesystems', () => {
+ it('projects QEMU guest-agent filesystems with stable override identities', () => {
+ createRoot((dispose) => {
+ const props = {
+ allGuests: () => [
+ {
+ id: 'cluster-a:node-1:100',
+ name: 'flatcar',
+ platformId: 'cluster-a',
+ status: 'online',
+ type: 'vm',
+ lastSeen: 1,
+ proxmox: {
+ instance: 'cluster-a',
+ node: 'node-1',
+ vmid: 100,
+ disks: [
+ {
+ device: '/dev/vda1',
+ free: 3,
+ mountpoint: '/boot',
+ total: 100,
+ type: 'ext4',
+ usage: 97,
+ used: 97,
+ },
+ ],
+ },
+ },
+ ],
+ backupDefaults: () => ({ enabled: false }),
+ guestDefaults: { disk: 85 },
+ nodes: [],
+ overrides: () => [
+ {
+ id: 'guest-disk:guest:cluster-a:100/disk:boot-dev-vda1',
+ name: '/boot',
+ type: 'guestDisk',
+ disabled: true,
+ thresholds: {},
+ },
+ ],
+ snapshotDefaults: () => ({ enabled: false }),
+ } as unknown as ThresholdsTableProps;
+
+ const data = useThresholdsGuestData({
+ props,
+ editingId: () => null,
+ searchTerm: () => '',
+ });
+
+ expect(data.guestDisksWithOverrides()).toEqual([
+ expect.objectContaining({
+ id: 'cluster-a:node-1:100-disk-boot-dev-vda1',
+ overrideStorageId: 'guest-disk:guest:cluster-a:100/disk:boot-dev-vda1',
+ name: '/boot',
+ node: 'flatcar',
+ type: 'guestDisk',
+ disabled: true,
+ hasOverride: true,
+ defaults: { disk: 85 },
+ }),
+ ]);
+ expect(Object.keys(data.guestDisksGroupedByGuest())).toEqual(['flatcar · cluster-a/100']);
+ dispose();
+ });
+ });
+
+ it('keeps a persisted filesystem override visible after its guest disappears', () => {
+ createRoot((dispose) => {
+ const props = {
+ allGuests: () => [],
+ backupDefaults: () => ({ enabled: false }),
+ guestDefaults: { disk: 85 },
+ nodes: [],
+ overrides: () => [
+ {
+ id: 'guest-disk:guest:cluster-a:100/disk:boot',
+ name: '/boot',
+ node: 'flatcar',
+ type: 'guestDisk',
+ thresholds: { disk: 99 },
+ },
+ ],
+ snapshotDefaults: () => ({ enabled: false }),
+ } as unknown as ThresholdsTableProps;
+
+ const data = useThresholdsGuestData({
+ props,
+ editingId: () => null,
+ searchTerm: () => '',
+ });
+
+ expect(data.guestDisksWithOverrides()).toEqual([
+ expect.objectContaining({
+ id: 'guest-disk:guest:cluster-a:100/disk:boot',
+ name: '/boot',
+ node: 'flatcar',
+ status: 'unknown',
+ thresholds: { disk: 99 },
+ }),
+ ]);
+ dispose();
+ });
+ });
+});
diff --git a/frontend-modern/src/features/alerts/thresholds/hooks/__tests__/useThresholdsOverrideMutations.test.tsx b/frontend-modern/src/features/alerts/thresholds/hooks/__tests__/useThresholdsOverrideMutations.test.tsx
index e123170c55..8d384ee26a 100644
--- a/frontend-modern/src/features/alerts/thresholds/hooks/__tests__/useThresholdsOverrideMutations.test.tsx
+++ b/frontend-modern/src/features/alerts/thresholds/hooks/__tests__/useThresholdsOverrideMutations.test.tsx
@@ -113,4 +113,64 @@ describe('useThresholdsOverrideMutations', () => {
expect(setHasUnsavedChanges).toHaveBeenCalledWith(true);
expect(cancelEdit).toHaveBeenCalledTimes(1);
});
+
+ it('bulk-saves guest filesystem thresholds under the stable override identity', () => {
+ const overrideSignal = createSignal<any[]>([]);
+ const { props, rawOverridesConfig } = buildTableProps(overrideSignal);
+ const filesystemResource: TableResource = {
+ id: 'cluster-a:node-2:100-disk-boot-dev-vda1',
+ overrideIdCandidates: [
+ 'guest-disk:guest:cluster-a:100/disk:boot-dev-vda1',
+ 'guest-disk:cluster-a:node-2:100/disk:boot-dev-vda1',
+ ],
+ overrideStorageId: 'guest-disk:guest:cluster-a:100/disk:boot-dev-vda1',
+ name: '/boot',
+ type: 'guestDisk',
+ resourceType: 'Guest Filesystem',
+ defaults: { disk: 85 },
+ thresholds: {},
+ };
+
+ const { result } = renderHook(() =>
+ useThresholdsOverrideMutations({
+ props,
+ resources: {
+ nodesWithOverrides: () => [],
+ agentsWithOverrides: () => [],
+ agentDisksWithOverrides: () => [],
+ guestDisksWithOverrides: () => [filesystemResource],
+ dockerHostsWithOverrides: () => [],
+ guestsFlat: () => [],
+ dockerContainersFlat: () => [],
+ pbsServersWithOverrides: () => [],
+ pmgServersWithOverrides: () => [],
+ storageWithOverrides: () => [],
+ },
+ editingThresholds: () => ({}),
+ editingNote: () => '',
+ bulkEditIds: () => [filesystemResource.id],
+ cancelEdit: vi.fn(),
+ updateBackupDefaults: vi.fn(),
+ updateSnapshotDefaults: vi.fn(),
+ }),
+ );
+
+ result.handleSaveBulkEdit({ disk: 99 });
+
+ expect(overrideSignal[0]()).toEqual([
+ expect.objectContaining({
+ id: 'guest-disk:guest:cluster-a:100/disk:boot-dev-vda1',
+ thresholds: { disk: 99 },
+ type: 'guestDisk',
+ }),
+ ]);
+ expect(rawOverridesConfig()).toEqual({
+ 'guest-disk:guest:cluster-a:100/disk:boot-dev-vda1': {
+ disk: {
+ clear: 94,
+ trigger: 99,
+ },
+ },
+ });
+ });
});
diff --git a/frontend-modern/src/features/alerts/thresholds/hooks/__tests__/useThresholdsTableState.test.tsx b/frontend-modern/src/features/alerts/thresholds/hooks/__tests__/useThresholdsTableState.test.tsx
index 8a1c413573..4bf706e226 100644
--- a/frontend-modern/src/features/alerts/thresholds/hooks/__tests__/useThresholdsTableState.test.tsx
+++ b/frontend-modern/src/features/alerts/thresholds/hooks/__tests__/useThresholdsTableState.test.tsx
@@ -37,6 +37,24 @@ vi.mock('../useThresholdsData', () => ({
dockerHostsWithOverrides: () => [],
guestsFlat: () => [],
guestsGroupedByNode: () => ({}),
+ guestDisksGroupedByGuest: () => ({
+ flatcar: [
+ {
+ id: 'cluster-a:node-1:100-disk-boot-dev-vda1',
+ name: '/boot',
+ type: 'guestDisk',
+ hasOverride: true,
+ },
+ ],
+ }),
+ guestDisksWithOverrides: () => [
+ {
+ id: 'cluster-a:node-1:100-disk-boot-dev-vda1',
+ name: '/boot',
+ type: 'guestDisk',
+ hasOverride: true,
+ },
+ ],
guestGroupHeaderMeta: () => ({}),
nodesWithOverrides: () => [],
pbsServersWithOverrides: () => [],
@@ -186,6 +204,8 @@ describe('useThresholdsTableState', () => {
expect(captured).toBeDefined();
expect(captured!.activeTab()).toBe('systems');
expect(captured!.hasDockerSpecificControls()).toBe(false);
+ expect(captured!.guestDisksWithOverrides()).toHaveLength(1);
+ expect(captured!.guestDisksGroupedByGuest().flatcar?.[0]?.name).toBe('/boot');
captured!.dismissHelpBanner();
expect(captured!.helpBannerDismissed()).toBe(true);
@@ -197,4 +217,25 @@ describe('useThresholdsTableState', () => {
captured!.handleTabClick('vmware');
expect(navigateSpy).toHaveBeenCalledWith('/alerts/thresholds/vmware');
});
+
+ it('includes guest filesystems in the Proxmox threshold summary', () => {
+ mockPathname = '/alerts/thresholds/proxmox';
+ let captured: ReturnType<typeof useThresholdsTableState> | undefined;
+
+ const Harness = () => {
+ captured = useThresholdsTableState(buildProps());
+ return null;
+ };
+
+ render(() => <Harness />);
+
+ expect(captured!.summaryItems()).toContainEqual(
+ expect.objectContaining({
+ key: 'guestDisks',
+ overrides: 1,
+ tab: 'proxmox',
+ total: 1,
+ }),
+ );
+ });
});
diff --git a/frontend-modern/src/features/alerts/thresholds/hooks/useThresholdsAvailabilityMutations.ts b/frontend-modern/src/features/alerts/thresholds/hooks/useThresholdsAvailabilityMutations.ts
index 29452e049a..13d911f9d7 100644
--- a/frontend-modern/src/features/alerts/thresholds/hooks/useThresholdsAvailabilityMutations.ts
+++ b/frontend-modern/src/features/alerts/thresholds/hooks/useThresholdsAvailabilityMutations.ts
@@ -23,6 +23,7 @@ interface ThresholdsAvailabilityMutationResources {
nodesWithOverrides: () => TableResource[];
agentsWithOverrides: () => TableResource[];
agentDisksWithOverrides: () => TableResource[];
+ guestDisksWithOverrides?: () => TableResource[];
dockerHostsWithOverrides: () => TableResource[];
guestsFlat: () => TableResource[];
dockerContainersFlat: () => TableResource[];
@@ -75,6 +76,7 @@ export function useThresholdsAvailabilityMutations({
...resources.pbsServersWithOverrides(),
...resources.agentsWithOverrides(),
...resources.agentDisksWithOverrides(),
+ ...optionalResources(resources.guestDisksWithOverrides),
...optionalResources(resources.kubernetesClustersWithOverrides),
...optionalResources(resources.kubernetesNodesWithOverrides),
...optionalResources(resources.kubernetesNamespacesWithOverrides),
@@ -98,6 +100,7 @@ export function useThresholdsAvailabilityMutations({
resource.type !== 'dockerContainer' &&
resource.type !== 'agent' &&
resource.type !== 'agentDisk' &&
+ resource.type !== 'guestDisk' &&
resource.type !== 'kubernetesCluster' &&
resource.type !== 'kubernetesNode' &&
resource.type !== 'kubernetesNamespace' &&
@@ -168,6 +171,8 @@ export function useThresholdsAvailabilityMutations({
props.removeAlerts(
(alert) => alert.resourceId === resourceId && alert.type === 'powered-off',
);
+ } else if (resource.type === 'guestDisk') {
+ props.removeAlerts((alert) => alert.resourceId === resourceId && alert.type === 'disk');
} else if (resource.type === 'pbs') {
const offlineId = `pbs-offline-${resourceId}`;
props.removeAlerts(
diff --git a/frontend-modern/src/features/alerts/thresholds/hooks/useThresholdsGuestData.ts b/frontend-modern/src/features/alerts/thresholds/hooks/useThresholdsGuestData.ts
index a3c9a85478..16f814830b 100644
--- a/frontend-modern/src/features/alerts/thresholds/hooks/useThresholdsGuestData.ts
+++ b/frontend-modern/src/features/alerts/thresholds/hooks/useThresholdsGuestData.ts
@@ -2,9 +2,13 @@ import { createMemo } from 'solid-js';
import {
getGuestOverrideIdentity,
+ guestDiskAlertResourceId,
+ guestDiskOverrideIdCandidates,
+ guestDiskOverrideStorageId,
guestOverrideIdCandidates,
} from '@/features/alerts/guestOverrideIdentity';
import { getAlertResourceDisplayLabel } from '@/features/alerts/helpers';
+import type { Disk } from '@/types/api';
import type { GroupHeaderMeta, Resource as TableResource } from '../tableTypes';
import { ThresholdsDataInputs } from '../thresholdsResourceModel';
@@ -97,6 +101,110 @@ export function useThresholdsGuestData(inputs: ThresholdsDataInputs) {
Object.values(guestsGroupedByNode() ?? {}).flat(),
);
+ const guestDisksWithOverrides = createMemo<TableResource[]>((prev = []) => {
+ if (editingId()) {
+ return prev;
+ }
+
+ const search = searchTerm().toLowerCase();
+ const overridesMap = createOverridesMap(props.overrides());
+ const seen = new Set<string>();
+ const guestDisks: TableResource[] = [];
+
+ (props.allGuests() ?? []).forEach((guest) => {
+ const disks = guest.proxmox?.disks ?? [];
+ const guestName = getAlertResourceDisplayLabel(guest);
+ const guestIdentity = getGuestOverrideIdentity(guest);
+
+ disks.forEach((disk: Disk) => {
+ if (!disk || disk.total <= 0 || disk.usage < 0) return;
+
+ const candidates = guestDiskOverrideIdCandidates(guest, disk.mountpoint, disk.device);
+ const storageId = guestDiskOverrideStorageId(guest, disk.mountpoint, disk.device);
+ const alertResourceId = guestDiskAlertResourceId(guest, disk.mountpoint, disk.device);
+ if (!storageId || !alertResourceId) return;
+
+ const override = findOverrideByCandidates(overridesMap, candidates);
+ const label = disk.mountpoint?.trim() || disk.device?.trim() || 'disk';
+ const hasCustomThresholds = hasThresholdDiff(override, {
+ disk: props.guestDefaults.disk,
+ });
+ candidates.forEach((candidate) => seen.add(candidate));
+ seen.add(storageId);
+
+ guestDisks.push({
+ id: alertResourceId,
+ overrideIdCandidates: candidates,
+ overrideStorageId: storageId,
+ name: label,
+ displayName: label,
+ rawName: disk.device || label,
+ type: 'guestDisk' as const,
+ resourceType: 'Guest Filesystem',
+ host: guest.id,
+ node: guestName,
+ groupKey: guestIdentity
+ ? `${guestName} · ${guestIdentity.instance}/${guestIdentity.vmid}`
+ : guestName,
+ instance: disk.type || '',
+ vmid: guestIdentity?.vmid,
+ status: guest.status,
+ hasOverride: hasCustomThresholds || Boolean(override?.disabled),
+ disabled: override?.disabled || false,
+ thresholds: override?.thresholds || {},
+ defaults: { disk: props.guestDefaults.disk },
+ subtitle: `${(disk.used / 1024 / 1024 / 1024).toFixed(1)} / ${(disk.total / 1024 / 1024 / 1024).toFixed(1)} GB · ${disk.usage.toFixed(1)}%`,
+ } satisfies TableResource);
+ });
+ });
+
+ (props.overrides() ?? [])
+ .filter((override) => override.type === 'guestDisk' && !seen.has(override.id))
+ .forEach((override) => {
+ const name = override.name || override.id;
+ guestDisks.push({
+ id: override.id,
+ overrideIdCandidates: [override.id],
+ overrideStorageId: override.id,
+ name,
+ displayName: name,
+ rawName: name,
+ type: 'guestDisk' as const,
+ resourceType: 'Guest Filesystem',
+ node: override.node || 'Unknown Guest',
+ instance: override.instance || '',
+ status: 'unknown',
+ hasOverride: true,
+ disabled: override.disabled || false,
+ thresholds: override.thresholds || {},
+ defaults: { disk: props.guestDefaults.disk },
+ });
+ });
+
+ return search
+ ? guestDisks.filter(
+ (disk) =>
+ disk.name.toLowerCase().includes(search) ||
+ disk.node?.toLowerCase().includes(search) ||
+ disk.rawName?.toLowerCase().includes(search),
+ )
+ : guestDisks;
+ }, []);
+
+ const guestDisksGroupedByGuest = createMemo<Record<string, TableResource[]>>(() => {
+ const grouped: Record<string, TableResource[]> = {};
+ guestDisksWithOverrides().forEach((disk) => {
+ const guestName =
+ (typeof disk.groupKey === 'string' && disk.groupKey.trim()) ||
+ disk.node?.trim() ||
+ 'Unknown Guest';
+ if (!grouped[guestName]) grouped[guestName] = [];
+ grouped[guestName].push(disk);
+ });
+ Object.values(grouped).forEach((disks) => disks.sort((a, b) => a.name.localeCompare(b.name)));
+ return grouped;
+ });
+
const guestGroupHeaderMeta = createMemo<Record<string, GroupHeaderMeta>>(() => {
const meta: Record<string, GroupHeaderMeta> = {};
(props.nodes ?? []).forEach((node) => {
@@ -109,6 +217,8 @@ export function useThresholdsGuestData(inputs: ThresholdsDataInputs) {
});
return {
+ guestDisksGroupedByGuest,
+ guestDisksWithOverrides,
guestsGroupedByNode,
guestsFlat,
guestGroupHeaderMeta,
diff --git a/frontend-modern/src/features/alerts/thresholds/hooks/useThresholdsOverrideMutations.ts b/frontend-modern/src/features/alerts/thresholds/hooks/useThresholdsOverrideMutations.ts
index 71cede6c5c..5187752816 100644
--- a/frontend-modern/src/features/alerts/thresholds/hooks/useThresholdsOverrideMutations.ts
+++ b/frontend-modern/src/features/alerts/thresholds/hooks/useThresholdsOverrideMutations.ts
@@ -31,6 +31,7 @@ interface ThresholdsOverrideMutationResources {
nodesWithOverrides: Accessor<TableResource[]>;
agentsWithOverrides: Accessor<TableResource[]>;
agentDisksWithOverrides: Accessor<TableResource[]>;
+ guestDisksWithOverrides?: Accessor<TableResource[]>;
dockerHostsWithOverrides: Accessor<TableResource[]>;
guestsFlat: Accessor<TableResource[]>;
dockerContainersFlat: Accessor<TableResource[]>;
@@ -84,6 +85,7 @@ export function useThresholdsOverrideMutations({
...resources.nodesWithOverrides(),
...resources.agentsWithOverrides(),
...resources.agentDisksWithOverrides(),
+ ...optionalResources(resources.guestDisksWithOverrides),
...resources.dockerHostsWithOverrides(),
...resources.pbsServersWithOverrides(),
...resources.pmgServersWithOverrides(),
@@ -281,9 +283,12 @@ export function useThresholdsOverrideMutations({
const resource = proxmoxResources().find((entry) => entry.id === id);
if (!resource) continue;
+ const { candidateIds, storageId } = getOverridePersistenceIdentity(resource);
const defaultThresholds = (resource.defaults ?? {}) as Record<string, number | undefined>;
- const existingOverride = nextOverrides.find((override) => override.id === id);
- const previousRaw = nextRawConfig[id];
+ const existingOverride = nextOverrides.find((override) => candidateIds.includes(override.id));
+ const previousRaw = candidateIds
+ .map((candidate) => nextRawConfig[candidate])
+ .find((entry): entry is RawOverrideConfig => Boolean(entry));
const newThresholds: Record<string, number | undefined> = {
...(existingOverride?.thresholds ?? {}),
};
@@ -309,14 +314,17 @@ export function useThresholdsOverrideMutations({
);
if (Object.keys(newThresholds).length === 0 && !hasStateOnlyOverride) {
- const existingIndex = nextOverrides.findIndex((override) => override.id === id);
- if (existingIndex !== -1) nextOverrides.splice(existingIndex, 1);
- delete nextRawConfig[id];
+ for (let index = nextOverrides.length - 1; index >= 0; index -= 1) {
+ if (candidateIds.includes(nextOverrides[index]!.id)) {
+ nextOverrides.splice(index, 1);
+ }
+ }
+ candidateIds.forEach((candidate) => delete nextRawConfig[candidate]);
continue;
}
const override: Override = {
- id,
+ id: storageId,
name: resource.name,
type: resource.type as OverrideType,
resourceType: resource.resourceType,
@@ -332,7 +340,7 @@ export function useThresholdsOverrideMutations({
thresholds: newThresholds,
};
- const existingIndex = nextOverrides.findIndex((entry) => entry.id === id);
+ const existingIndex = nextOverrides.findIndex((entry) => candidateIds.includes(entry.id));
if (existingIndex >= 0) {
nextOverrides[existingIndex] = override;
} else {
@@ -356,7 +364,8 @@ export function useThresholdsOverrideMutations({
}
}
- nextRawConfig[id] = withThresholdEntries(hysteresisThresholds, newThresholds);
+ candidateIds.forEach((candidate) => delete nextRawConfig[candidate]);
+ nextRawConfig[storageId] = withThresholdEntries(hysteresisThresholds, newThresholds);
}
props.setOverrides(nextOverrides);
diff --git a/frontend-modern/src/features/alerts/thresholds/hooks/useThresholdsTableState.ts b/frontend-modern/src/features/alerts/thresholds/hooks/useThresholdsTableState.ts
index 3037b7a6ed..dc3042d534 100644
--- a/frontend-modern/src/features/alerts/thresholds/hooks/useThresholdsTableState.ts
+++ b/frontend-modern/src/features/alerts/thresholds/hooks/useThresholdsTableState.ts
@@ -21,6 +21,8 @@ import {
BACKUP_THRESHOLDS_EMPTY_STATE,
CONTAINERS_FILTER_EMPTY_STATE,
CONTAINER_RUNTIMES_FILTER_EMPTY_STATE,
+ GUEST_DISKS_EMPTY_STATE,
+ GUEST_DISKS_FILTER_EMPTY_STATE,
GUEST_THRESHOLDS_EMPTY_STATE,
GUEST_THRESHOLDS_FILTER_EMPTY_STATE,
GUEST_FILTERING_EMPTY_STATE,
@@ -55,6 +57,7 @@ interface ThresholdsSummaryItem {
| 'backups'
| 'dockerContainers'
| 'dockerHosts'
+ | 'guestDisks'
| 'guests'
| 'kubernetesClusters'
| 'kubernetesDeployments'
@@ -261,6 +264,8 @@ export function useThresholdsTableState(props: ThresholdsTableProps) {
guestsGroupedByNode: rawGuestsGroupedByNode,
guestsFlat: rawGuestsFlat,
guestGroupHeaderMeta,
+ guestDisksGroupedByGuest: rawGuestDisksGroupedByGuest = () => ({}),
+ guestDisksWithOverrides: rawGuestDisksWithOverrides = () => [],
kubernetesClustersWithOverrides: rawKubernetesClustersWithOverrides = () => [],
kubernetesDeploymentsWithOverrides: rawKubernetesDeploymentsWithOverrides = () => [],
kubernetesNamespacesWithOverrides: rawKubernetesNamespacesWithOverrides = () => [],
@@ -323,6 +328,10 @@ export function useThresholdsTableState(props: ThresholdsTableProps) {
const dockerContainersFlat = createMemo(() => filterResources(rawDockerContainersFlat()));
const guestsGroupedByNode = createMemo(() => filterGroupedResources(rawGuestsGroupedByNode()));
const guestsFlat = createMemo(() => filterResources(rawGuestsFlat()));
+ const guestDisksGroupedByGuest = createMemo(() =>
+ filterGroupedResources(rawGuestDisksGroupedByGuest()),
+ );
+ const guestDisksWithOverrides = createMemo(() => filterResources(rawGuestDisksWithOverrides()));
const kubernetesClustersWithOverrides = createMemo(() =>
filterResources(rawKubernetesClustersWithOverrides()),
);
@@ -564,6 +573,13 @@ export function useThresholdsTableState(props: ThresholdsTableProps) {
tab: 'proxmox',
total: props.allGuests?.()?.length ?? 0,
},
+ {
+ key: 'guestDisks',
+ label: 'Guest Filesystems',
+ overrides: countOverrides(guestDisksWithOverrides()),
+ tab: 'proxmox',
+ total: guestDisksWithOverrides().length,
+ },
{
key: 'kubernetesClusters',
label: 'Kubernetes Clusters',
@@ -697,6 +713,7 @@ export function useThresholdsTableState(props: ThresholdsTableProps) {
nodesWithOverrides,
agentsWithOverrides,
agentDisksWithOverrides,
+ guestDisksWithOverrides,
dockerHostsWithOverrides,
guestsFlat,
dockerContainersFlat,
@@ -732,6 +749,7 @@ export function useThresholdsTableState(props: ThresholdsTableProps) {
nodesWithOverrides,
agentsWithOverrides,
agentDisksWithOverrides,
+ guestDisksWithOverrides,
dockerHostsWithOverrides,
guestsFlat,
dockerContainersFlat,
@@ -865,10 +883,14 @@ export function useThresholdsTableState(props: ThresholdsTableProps) {
editingNote,
editingThresholds,
expandAll,
+ GUEST_DISKS_EMPTY_STATE,
+ GUEST_DISKS_FILTER_EMPTY_STATE,
GUEST_FILTERING_EMPTY_STATE,
GUEST_THRESHOLDS_EMPTY_STATE,
GUEST_THRESHOLDS_FILTER_EMPTY_STATE,
guestFilterPresentation,
+ guestDisksGroupedByGuest,
+ guestDisksWithOverrides,
guestGroupHeaderMeta,
guestsFlat,
guestsGroupedByNode,
diff --git a/frontend-modern/src/features/alerts/thresholds/types.ts b/frontend-modern/src/features/alerts/thresholds/types.ts
index a3270b7bd0..b3306aa9b6 100644
--- a/frontend-modern/src/features/alerts/thresholds/types.ts
+++ b/frontend-modern/src/features/alerts/thresholds/types.ts
@@ -10,6 +10,7 @@ import type { AlertIntentSignal } from '@/api/alertIntentPolicies';
export type OverrideType =
| 'guest'
+ | 'guestDisk'
| 'agent'
| 'agentDisk'
| 'storage'
diff --git a/frontend-modern/src/features/alerts/types.ts b/frontend-modern/src/features/alerts/types.ts
index 0a47a288d8..c4cd9af6aa 100644
--- a/frontend-modern/src/features/alerts/types.ts
+++ b/frontend-modern/src/features/alerts/types.ts
@@ -85,6 +85,7 @@ export interface DestinationsRef {
// Override interface for both guests and nodes
export type OverrideType =
| 'guest'
+ | 'guestDisk'
| 'agent'
| 'agentDisk'
| 'storage'
diff --git a/frontend-modern/src/utils/__tests__/alertThresholdsPresentation.test.ts b/frontend-modern/src/utils/__tests__/alertThresholdsPresentation.test.ts
index 317fa40f44..1ea0ce479c 100644
--- a/frontend-modern/src/utils/__tests__/alertThresholdsPresentation.test.ts
+++ b/frontend-modern/src/utils/__tests__/alertThresholdsPresentation.test.ts
@@ -198,6 +198,7 @@ describe('alertThresholdsPresentation', () => {
nodes: 'Virtualization Hosts',
pbs: 'PBS Servers',
guests: 'VMs & Containers',
+ guestDisks: 'Guest Filesystems',
guestFiltering: 'VM and Container Filtering',
backups: 'Recovery',
snapshots: 'Snapshot Age',
diff --git a/frontend-modern/src/utils/alertThresholdsPresentation.ts b/frontend-modern/src/utils/alertThresholdsPresentation.ts
index bfa5809a7f..9eb569fa67 100644
--- a/frontend-modern/src/utils/alertThresholdsPresentation.ts
+++ b/frontend-modern/src/utils/alertThresholdsPresentation.ts
@@ -7,6 +7,9 @@ export const NODE_THRESHOLDS_FILTER_EMPTY_STATE =
export const PBS_THRESHOLDS_FILTER_EMPTY_STATE = 'No PBS servers match the current filters.';
export const GUEST_THRESHOLDS_FILTER_EMPTY_STATE =
'No VMs or containers match the current filters.';
+export const GUEST_DISKS_EMPTY_STATE =
+ 'No guest filesystems found. Filesystems reported by QEMU guest agents will appear here.';
+export const GUEST_DISKS_FILTER_EMPTY_STATE = 'No guest filesystems match the current filters.';
export const GUEST_FILTERING_EMPTY_STATE = 'Configure VM and container filtering rules.';
export const BACKUP_THRESHOLDS_EMPTY_STATE = 'Configure recovery alert thresholds.';
export const SNAPSHOT_THRESHOLDS_EMPTY_STATE = 'Configure snapshot age thresholds.';
@@ -77,6 +80,7 @@ export const ALERT_THRESHOLDS_DOCKER_UPDATES_DELAY_DESCRIPTION =
export const ALERT_THRESHOLDS_SECTION_TITLE_NODES = 'Virtualization Hosts';
export const ALERT_THRESHOLDS_SECTION_TITLE_PBS = 'PBS Servers';
export const ALERT_THRESHOLDS_SECTION_TITLE_GUESTS = 'VMs & Containers';
+export const ALERT_THRESHOLDS_SECTION_TITLE_GUEST_DISKS = 'Guest Filesystems';
export const ALERT_THRESHOLDS_SECTION_TITLE_GUEST_FILTERING = 'VM and Container Filtering';
export const ALERT_THRESHOLDS_SECTION_TITLE_BACKUPS = 'Recovery';
export const ALERT_THRESHOLDS_SECTION_TITLE_SNAPSHOTS = 'Snapshot Age';
@@ -176,6 +180,7 @@ export function getAlertThresholdsSectionTitles() {
nodes: ALERT_THRESHOLDS_SECTION_TITLE_NODES,
pbs: ALERT_THRESHOLDS_SECTION_TITLE_PBS,
guests: ALERT_THRESHOLDS_SECTION_TITLE_GUESTS,
+ guestDisks: ALERT_THRESHOLDS_SECTION_TITLE_GUEST_DISKS,
guestFiltering: ALERT_THRESHOLDS_SECTION_TITLE_GUEST_FILTERING,
backups: ALERT_THRESHOLDS_SECTION_TITLE_BACKUPS,
snapshots: ALERT_THRESHOLDS_SECTION_TITLE_SNAPSHOTS,
diff --git a/internal/alerts/guest.go b/internal/alerts/guest.go
index 0d824f29b9..46b22f50bc 100644
--- a/internal/alerts/guest.go
+++ b/internal/alerts/guest.go
@@ -6,6 +6,7 @@ import (
"time"
alertspecs "github.com/rcourtman/pulse-go-rewrite/internal/alerts/specs"
+ "github.com/rcourtman/pulse-go-rewrite/internal/models"
"github.com/rcourtman/pulse-go-rewrite/internal/unifiedresources"
"github.com/rs/zerolog/log"
)
@@ -267,6 +268,44 @@ func (m *Manager) CheckGuest(guest any, instanceName string) {
memoryMetric = &UnifiedResourceMetric{Percent: memUsage}
}
diskReadMetric, diskWriteMetric, networkInMetric, networkOutMetric := guestIORateMetrics(snapshot)
+ diskMetric := &UnifiedResourceMetric{Percent: diskUsage}
+ if len(disks) > 0 {
+ var aggregateTotal, aggregateUsed int64
+ hasDedicatedDiskOverride := false
+ seenAggregateDiskKeys := make(map[string]struct{})
+ for idx, disk := range disks {
+ if disk.Total <= 0 || disk.Usage < 0 {
+ continue
+ }
+ label, keySource, sanitizedKey := guestDiskIdentity(disk, idx)
+ if _, exists := seenAggregateDiskKeys[sanitizedKey]; exists {
+ continue
+ }
+ seenAggregateDiskKeys[sanitizedKey] = struct{}{}
+
+ m.mu.RLock()
+ diskOverride, hasDiskOverride := lookupGuestDiskOverride(m.config.Overrides, guest, guestID, keySource)
+ m.mu.RUnlock()
+ if hasDiskOverride && (diskOverride.Disabled || diskOverride.Disk != nil) {
+ hasDedicatedDiskOverride = true
+ log.Debug().
+ Str("guest", name).
+ Str("diskLabel", label).
+ Msg("Excluding guest filesystem with a dedicated override from aggregate disk alert")
+ continue
+ }
+ aggregateTotal += disk.Total
+ aggregateUsed += disk.Used
+ }
+ if hasDedicatedDiskOverride {
+ if aggregateTotal > 0 {
+ diskMetric.Percent = float64(aggregateUsed) / float64(aggregateTotal) * 100
+ } else {
+ diskMetric = nil
+ m.clearAlert(canonicalMetricStateID(guestID, "disk"))
+ }
+ }
+ }
m.evaluateUnifiedMetrics(&UnifiedResourceInput{
ID: guestID,
Type: snapshot.resourceType(),
@@ -275,14 +314,14 @@ func (m *Manager) CheckGuest(guest any, instanceName string) {
Instance: instanceName,
CPU: &UnifiedResourceMetric{Percent: cpu},
Memory: memoryMetric,
- Disk: &UnifiedResourceMetric{Percent: diskUsage},
+ Disk: diskMetric,
DiskRead: diskReadMetric,
DiskWrite: diskWriteMetric,
NetworkIn: networkInMetric,
NetworkOut: networkOutMetric,
}, thresholds, evalOpts)
- if thresholds.Disk != nil && thresholds.Disk.Trigger > 0 && len(disks) > 0 {
+ if len(disks) > 0 {
seenDiskKeys := make(map[string]struct{})
seenDiskResources := make(map[string]struct{})
for idx, disk := range disks {
@@ -293,22 +332,7 @@ func (m *Manager) CheckGuest(guest any, instanceName string) {
continue
}
- label := strings.TrimSpace(disk.Mountpoint)
- if label == "" {
- label = strings.TrimSpace(disk.Device)
- }
- if label == "" {
- label = fmt.Sprintf("Disk %d", idx+1)
- }
-
- keySource := label
- if disk.Device != "" && !strings.EqualFold(disk.Device, label) {
- keySource = fmt.Sprintf("%s-%s", label, disk.Device)
- }
- sanitizedKey := sanitizeAlertKey(keySource)
- if sanitizedKey == "" {
- sanitizedKey = fmt.Sprintf("disk-%d", idx+1)
- }
+ label, keySource, sanitizedKey := guestDiskIdentity(disk, idx)
// Avoid duplicate checks if two disks resolve to the same key
if _, exists := seenDiskKeys[sanitizedKey]; exists {
@@ -320,6 +344,20 @@ func (m *Manager) CheckGuest(guest any, instanceName string) {
seenDiskResources[perDiskResourceID] = struct{}{}
message := fmt.Sprintf("%s disk (%s) at %.1f%%", guestType, label, disk.Usage)
+ effectiveDiskThreshold := thresholds.Disk
+ m.mu.RLock()
+ diskOverride, hasDiskOverride := lookupGuestDiskOverride(m.config.Overrides, guest, guestID, keySource)
+ m.mu.RUnlock()
+ if hasDiskOverride {
+ if diskOverride.Disabled {
+ m.clearAlert(canonicalMetricStateID(perDiskResourceID, "disk"))
+ continue
+ }
+ if diskOverride.Disk != nil {
+ effectiveDiskThreshold = ensureHysteresisThreshold(diskOverride.Disk)
+ }
+ }
+
log.Debug().
Str("guest", name).
Str("node", node).
@@ -340,14 +378,14 @@ func (m *Manager) CheckGuest(guest any, instanceName string) {
}
resourceType, ok := unifiedMetricResourceType(snapshot.resourceType())
if !ok {
- m.checkMetric(perDiskResourceID, name, node, instanceName, snapshot.resourceType(), "disk", disk.Usage, thresholds.Disk, &metricOptions{
+ m.checkMetric(perDiskResourceID, name, node, instanceName, snapshot.resourceType(), "disk", disk.Usage, effectiveDiskThreshold, &metricOptions{
Metadata: metadata,
Message: message,
MonitorOnly: monitorOnly,
})
continue
}
- spec, err := buildCanonicalMetricSpec(perDiskResourceID, name, resourceType, "disk", thresholds.Disk)
+ spec, err := buildCanonicalMetricSpec(perDiskResourceID, name, resourceType, "disk", effectiveDiskThreshold)
if err != nil {
log.Warn().
Err(err).
@@ -357,7 +395,7 @@ func (m *Manager) CheckGuest(guest any, instanceName string) {
continue
}
- m.checkMetricWithCanonicalSpec(spec, name, node, instanceName, snapshot.resourceType(), disk.Usage, thresholds.Disk, &metricOptions{
+ m.checkMetricWithCanonicalSpec(spec, name, node, instanceName, snapshot.resourceType(), disk.Usage, effectiveDiskThreshold, &metricOptions{
Metadata: metadata,
Message: message,
MonitorOnly: monitorOnly,
@@ -371,6 +409,26 @@ func (m *Manager) CheckGuest(guest any, instanceName string) {
}
}
+func guestDiskIdentity(disk models.Disk, idx int) (label, keySource, sanitizedKey string) {
+ label = strings.TrimSpace(disk.Mountpoint)
+ if label == "" {
+ label = strings.TrimSpace(disk.Device)
+ }
+ if label == "" {
+ label = fmt.Sprintf("Disk %d", idx+1)
+ }
+
+ keySource = label
+ if disk.Device != "" && !strings.EqualFold(disk.Device, label) {
+ keySource = fmt.Sprintf("%s-%s", label, disk.Device)
+ }
+ sanitizedKey = sanitizeAlertKey(keySource)
+ if sanitizedKey == "" {
+ sanitizedKey = fmt.Sprintf("disk-%d", idx+1)
+ }
+ return label, keySource, sanitizedKey
+}
+
func guestIORateMetrics(snapshot guestSnapshot) (diskRead, diskWrite, networkIn, networkOut *UnifiedResourceMetric) {
validity := snapshot.IORateValidity.EffectiveForRates(
snapshot.DiskRead,
diff --git a/internal/alerts/guest_override_identity.go b/internal/alerts/guest_override_identity.go
index 15b1b1c425..669a76e48e 100644
--- a/internal/alerts/guest_override_identity.go
+++ b/internal/alerts/guest_override_identity.go
@@ -131,6 +131,64 @@ func clusteredGuestOverrideKey(ident guestOverrideIdentity) string {
return stableGuestOverrideKey(ident.instance, ident.vmid)
}
+func guestOverridePrimaryKey(guest any, guestID string) string {
+ ident, ok := guestOverrideIdentityFromGuestOrID(guest, guestID)
+ if !ok {
+ return strings.TrimSpace(guestID)
+ }
+ if stableKey := clusteredGuestOverrideKey(ident); stableKey != "" {
+ return stableKey
+ }
+ return fmt.Sprintf("%s:%s:%d", ident.instance, ident.node, ident.vmid)
+}
+
+func guestDiskOverrideKey(guest any, guestID, diskKey string) string {
+ base := guestOverridePrimaryKey(guest, guestID)
+ diskKey = sanitizeAlertKey(diskKey)
+ if base == "" || diskKey == "" {
+ return ""
+ }
+ return fmt.Sprintf("guest-disk:%s/disk:%s", base, diskKey)
+}
+
+func lookupGuestDiskOverride(overrides map[string]ThresholdConfig, guest any, guestID, diskKey string) (ThresholdConfig, bool) {
+ ident, hasIdentity := guestOverrideIdentityFromGuestOrID(guest, guestID)
+ candidates := make([]string, 0, 5)
+ sanitizedDiskKey := sanitizeAlertKey(diskKey)
+ addCandidate := func(base string) {
+ base = strings.TrimSpace(base)
+ if base == "" || sanitizedDiskKey == "" {
+ return
+ }
+ key := fmt.Sprintf("guest-disk:%s/disk:%s", base, sanitizedDiskKey)
+ for _, existing := range candidates {
+ if existing == key {
+ return
+ }
+ }
+ candidates = append(candidates, key)
+ }
+
+ if hasIdentity {
+ if stableKey := clusteredGuestOverrideKey(ident); stableKey != "" {
+ addCandidate(stableKey)
+ }
+ addCandidate(fmt.Sprintf("%s:%s:%d", ident.instance, ident.node, ident.vmid))
+ addCandidate(legacyGuestStableOverrideKey(ident.instance, ident.vmid))
+ if ident.instance != ident.node {
+ addCandidate(legacyClusterGuestOverrideKey(ident.instance, ident.node, ident.vmid))
+ }
+ }
+ addCandidate(strings.TrimSpace(guestID))
+
+ for _, candidate := range candidates {
+ if override, ok := overrides[candidate]; ok {
+ return override, true
+ }
+ }
+ return ThresholdConfig{}, false
+}
+
func lookupGuestOverride(overrides map[string]ThresholdConfig, guest any, guestID string) (ThresholdConfig, bool) {
ident, ok := guestOverrideIdentityFromGuestOrID(guest, guestID)
if ok {
diff --git a/internal/alerts/threshold_resolution_shared_test.go b/internal/alerts/threshold_resolution_shared_test.go
index d0dc515124..316699c50f 100644
--- a/internal/alerts/threshold_resolution_shared_test.go
+++ b/internal/alerts/threshold_resolution_shared_test.go
@@ -834,3 +834,108 @@ func TestReevaluateActiveAlertsUsesVMwareResourceTypeMetadata(t *testing.T) {
t.Fatalf("expected vSphere metric alert to resolve when vSphere usage threshold is disabled")
}
}
+
+func TestGuestFilesystemDisableOverrideExcludesMountAndAggregate(t *testing.T) {
+ m := newTestManager(t)
+ guestID := BuildGuestKey("pve1", "node1", 101)
+
+ m.mu.Lock()
+ m.config.TimeThresholds = map[string]int{}
+ m.config.GuestDefaults = ThresholdConfig{
+ Disk: &HysteresisThreshold{Trigger: 80, Clear: 75},
+ }
+ m.config.Overrides = map[string]ThresholdConfig{
+ "guest-disk:pve1:node1:101/disk:boot-dev-vda1": {Disabled: true},
+ }
+ m.mu.Unlock()
+
+ m.CheckGuest(models.VM{
+ ID: guestID,
+ VMID: 101,
+ Name: "flatcar",
+ Node: "node1",
+ Instance: "pve1",
+ Status: "running",
+ Disk: models.Disk{Usage: 97},
+ Disks: []models.Disk{
+ {Mountpoint: "/boot", Device: "/dev/vda1", Usage: 97, Total: 100, Used: 97, Free: 3},
+ {Mountpoint: "/", Device: "/dev/vda2", Usage: 50, Total: 100, Used: 50, Free: 50},
+ },
+ }, "pve1")
+
+ bootAlertID := canonicalMetricStateID(guestID+"-disk-boot-dev-vda1", "disk")
+ rootAlertID := canonicalMetricStateID(guestID+"-disk-dev-vda2", "disk")
+ aggregateAlertID := canonicalMetricStateID(guestID, "disk")
+
+ m.mu.RLock()
+ defer m.mu.RUnlock()
+ if _, exists := testLookupActiveAlert(t, m, bootAlertID); exists {
+ t.Fatalf("disabled /boot filesystem created alert %q", bootAlertID)
+ }
+ if _, exists := testLookupActiveAlert(t, m, rootAlertID); exists {
+ t.Fatalf("healthy root filesystem created alert %q", rootAlertID)
+ }
+ if _, exists := testLookupActiveAlert(t, m, aggregateAlertID); exists {
+ t.Fatalf("disabled /boot filesystem leaked into aggregate alert %q", aggregateAlertID)
+ }
+}
+
+func TestGuestFilesystemThresholdOverrideOwnsMountEvaluation(t *testing.T) {
+ m := newTestManager(t)
+ guestID := BuildGuestKey("pve1", "node1", 101)
+
+ m.mu.Lock()
+ m.config.TimeThresholds = map[string]int{}
+ m.config.GuestDefaults = ThresholdConfig{
+ Disk: &HysteresisThreshold{Trigger: 80, Clear: 75},
+ }
+ m.config.Overrides = map[string]ThresholdConfig{
+ "guest-disk:guest:pve1:101/disk:boot-dev-vda1": {
+ Disk: &HysteresisThreshold{Trigger: 99, Clear: 95},
+ },
+ }
+ aggregateAlertID := canonicalMetricStateID(guestID, "disk")
+ m.activeAlerts[aggregateAlertID] = &Alert{
+ ID: aggregateAlertID,
+ ResourceID: guestID,
+ Type: "disk",
+ Value: 97,
+ }
+ m.mu.Unlock()
+
+ vm := models.VM{
+ ID: guestID,
+ VMID: 101,
+ Name: "flatcar",
+ Node: "node1",
+ Instance: "pve1",
+ Status: "running",
+ Disks: []models.Disk{
+ {Mountpoint: "/boot", Device: "/dev/vda1", Usage: 97, Total: 100, Used: 97, Free: 3},
+ },
+ }
+ m.CheckGuest(vm, "pve1")
+
+ bootAlertID := canonicalMetricStateID(guestID+"-disk-boot-dev-vda1", "disk")
+ m.mu.RLock()
+ _, existsAt97 := testLookupActiveAlert(t, m, bootAlertID)
+ _, aggregateExists := testLookupActiveAlert(t, m, aggregateAlertID)
+ m.mu.RUnlock()
+ if existsAt97 {
+ t.Fatalf("/boot alert fired below its 99%% override")
+ }
+ if aggregateExists {
+ t.Fatalf("dedicated filesystem override left stale aggregate alert %q", aggregateAlertID)
+ }
+
+ vm.Disks[0].Usage = 100
+ vm.Disks[0].Used = 100
+ vm.Disks[0].Free = 0
+ m.CheckGuest(vm, "pve1")
+
+ m.mu.RLock()
+ defer m.mu.RUnlock()
+ if _, exists := testLookupActiveAlert(t, m, bootAlertID); !exists {
+ t.Fatalf("/boot alert did not fire above its 99%% override")
+ }
+}