diff --git a/client/src/Pages/v1/Infrastructure/Create/hooks/useInfrastructureMonitorForm.jsx b/client/src/Pages/v1/Infrastructure/Create/hooks/useInfrastructureMonitorForm.jsx index f0a701517..ea92829c9 100644 --- a/client/src/Pages/v1/Infrastructure/Create/hooks/useInfrastructureMonitorForm.jsx +++ b/client/src/Pages/v1/Infrastructure/Create/hooks/useInfrastructureMonitorForm.jsx @@ -31,14 +31,17 @@ const useInfrastructureMonitorForm = () => { [event.target.name]: event.target.checked, }); }; - const initializeInfrastructureMonitorForCreate = useCallback((globalSettings) => { + const initializeInfrastructureMonitorForCreate = useCallback((globalSettings, monitorType = "hardware") => { const gt = globalSettings?.data?.settings?.globalThresholds || {}; + // Docker monitors default to 30 seconds (0.5 minutes), hardware to 15 seconds (0.25 minutes) + const defaultInterval = monitorType === "docker" ? 0.5 : 0.25; + setInfrastructureMonitor((prev) => ({ ...prev, url: "", name: "", notifications: [], - interval: 0.25, + interval: defaultInterval, cpu: gt.cpu !== undefined, usage_cpu: gt.cpu !== undefined ? gt.cpu.toString() : "", memory: gt.memory !== undefined, diff --git a/client/src/Pages/v1/Infrastructure/Create/index.jsx b/client/src/Pages/v1/Infrastructure/Create/index.jsx index 7eb85f758..0f817dc0d 100644 --- a/client/src/Pages/v1/Infrastructure/Create/index.jsx +++ b/client/src/Pages/v1/Infrastructure/Create/index.jsx @@ -35,9 +35,6 @@ const CreateInfrastructureMonitor = () => { const theme = useTheme(); const { t } = useTranslation(); - // Get monitor type from query params (default to hardware for backwards compatibility) - const monitorType = searchParams.get("type") || "hardware"; - // State const [https, setHttps] = useState(false); const [updateTrigger, setUpdateTrigger] = useState(false); @@ -47,6 +44,11 @@ const CreateInfrastructureMonitor = () => { monitorId, updateTrigger, }); + + // Determine monitor type: from query params when creating, from monitor object when editing + const monitorType = isCreate + ? (searchParams.get("type") || "hardware") + : (monitor?.type || "hardware"); const [deleteMonitor, isDeleting] = useDeleteMonitor(); const [globalSettings, globalSettingsLoading] = useFetchGlobalSettings(); const [notifications, notificationsAreLoading] = useGetNotificationsByTeamId(); @@ -91,7 +93,8 @@ const CreateInfrastructureMonitor = () => { if (isCreate) { if (globalSettingsLoading) return; setHttps(false); - initializeInfrastructureMonitorForCreate(globalSettings); + const typeFromQuery = searchParams.get("type") || "hardware"; + initializeInfrastructureMonitorForCreate(globalSettings, typeFromQuery); } else if (monitor) { setHttps(monitor.url.startsWith("https")); initializeInfrastructureMonitorForUpdate(monitor); @@ -101,6 +104,7 @@ const CreateInfrastructureMonitor = () => { monitor, globalSettings, globalSettingsLoading, + searchParams, initializeInfrastructureMonitorForCreate, initializeInfrastructureMonitorForUpdate, ]); diff --git a/client/src/Pages/v1/Infrastructure/Details/Components/DockerContainersTable/index.jsx b/client/src/Pages/v1/Infrastructure/Details/Components/DockerContainersTable/index.jsx index 2d1ee12aa..53ecaf746 100644 --- a/client/src/Pages/v1/Infrastructure/Details/Components/DockerContainersTable/index.jsx +++ b/client/src/Pages/v1/Infrastructure/Details/Components/DockerContainersTable/index.jsx @@ -3,7 +3,7 @@ import { useTheme } from "@emotion/react"; import DataTable from "@/Components/v1/Table/index.jsx"; import { StatusLabel } from "@/Components/v1/Label/index.jsx"; -const DockerContainersTable = ({ containers = [] }) => { +const DockerContainersTable = ({ containers = [], errors = [], captureVersion }) => { const theme = useTheme(); // Helper to format uptime @@ -136,7 +136,22 @@ const DockerContainersTable = ({ containers = [] }) => { }, ]; + // Check if there are critical errors (Docker daemon down) + const dockerClientError = errors.find((e) => e.metric && e.metric.includes("docker.client")); + if (!containers || containers.length === 0) { + // Determine the message based on error type + let message = "No containers found"; + let errorDetails = null; + + if (dockerClientError) { + message = "Docker daemon unavailable"; + errorDetails = dockerClientError.err; + } else if (errors && errors.length > 0) { + message = "Partial data available"; + errorDetails = "Some containers could not be inspected"; + } + return ( { textAlign: "center", border: `1px solid ${theme.palette.divider}`, borderRadius: theme.spacing(2), + backgroundColor: dockerClientError ? theme.palette.error.lighter : undefined, }} > - No containers found + {message} + {errorDetails && ( + + {errorDetails} + + )} + {captureVersion && ( + + Capture version: {captureVersion} + + )} ); } return ( - - Docker Containers ({containers.length}) - + + + Docker Containers ({containers.length}) + + {errors && errors.length > 0 && ( + + ⚠ {errors.length} error(s) encountered while fetching container data + + )} + {captureVersion && ( + + Capture version: {captureVersion} + + )} + { /> )} diff --git a/client/src/Pages/v1/Infrastructure/Monitors/index.jsx b/client/src/Pages/v1/Infrastructure/Monitors/index.jsx index bef4330e9..db4561149 100644 --- a/client/src/Pages/v1/Infrastructure/Monitors/index.jsx +++ b/client/src/Pages/v1/Infrastructure/Monitors/index.jsx @@ -115,7 +115,7 @@ const InfrastructureMonitors = () => { isLoading={isLoading} items={monitors} type="infrastructureMonitor" - fallbackLink="/infrastructure/create" + fallbackLink="/infrastructure/create?type=hardware" > @@ -161,7 +161,7 @@ const InfrastructureMonitors = () => { isLoading={isLoading} items={monitors} type="infrastructureMonitor" - fallbackLink="/infrastructure/create" + fallbackLink="/infrastructure/create?type=docker" >