diff --git a/client/src/Pages/v1/Infrastructure/Create/hooks/useInfrastructureSubmit.jsx b/client/src/Pages/v1/Infrastructure/Create/hooks/useInfrastructureSubmit.jsx
index 8a97486c7..6bd075ba2 100644
--- a/client/src/Pages/v1/Infrastructure/Create/hooks/useInfrastructureSubmit.jsx
+++ b/client/src/Pages/v1/Infrastructure/Create/hooks/useInfrastructureSubmit.jsx
@@ -5,7 +5,7 @@ import {
const useInfrastructureSubmit = () => {
const [createMonitor, isCreating] = useCreateMonitor();
const [updateMonitor, isUpdating] = useUpdateMonitor();
- const buildForm = (infrastructureMonitor, https) => {
+ const buildForm = (infrastructureMonitor, https, monitorType = "hardware") => {
const MS_PER_MINUTE = 60000;
let form = {
@@ -17,31 +17,37 @@ const useInfrastructureSubmit = () => {
interval: infrastructureMonitor.interval * MS_PER_MINUTE,
statusWindowSize: infrastructureMonitor.statusWindowSize,
statusWindowThreshold: infrastructureMonitor.statusWindowThreshold,
- cpu: infrastructureMonitor.cpu,
- ...(infrastructureMonitor.cpu
- ? { usage_cpu: infrastructureMonitor.usage_cpu }
- : {}),
- memory: infrastructureMonitor.memory,
- ...(infrastructureMonitor.memory
- ? { usage_memory: infrastructureMonitor.usage_memory }
- : {}),
- disk: infrastructureMonitor.disk,
- ...(infrastructureMonitor.disk
- ? { usage_disk: infrastructureMonitor.usage_disk }
- : {}),
- temperature: infrastructureMonitor.temperature,
- ...(infrastructureMonitor.temperature
- ? { usage_temperature: infrastructureMonitor.usage_temperature }
- : {}),
secret: infrastructureMonitor.secret,
};
+
+ // Only add hardware-specific thresholds for hardware monitors
+ if (monitorType === "hardware") {
+ form.cpu = infrastructureMonitor.cpu;
+ if (infrastructureMonitor.cpu) {
+ form.usage_cpu = infrastructureMonitor.usage_cpu;
+ }
+ form.memory = infrastructureMonitor.memory;
+ if (infrastructureMonitor.memory) {
+ form.usage_memory = infrastructureMonitor.usage_memory;
+ }
+ form.disk = infrastructureMonitor.disk;
+ if (infrastructureMonitor.disk) {
+ form.usage_disk = infrastructureMonitor.usage_disk;
+ }
+ form.temperature = infrastructureMonitor.temperature;
+ if (infrastructureMonitor.temperature) {
+ form.usage_temperature = infrastructureMonitor.usage_temperature;
+ }
+ }
+
return form;
};
const submitInfrastructureForm = async (
infrastructureMonitor,
form,
isCreate,
- monitorId
+ monitorId,
+ monitorType = "hardware"
) => {
const {
cpu,
@@ -55,20 +61,24 @@ const useInfrastructureSubmit = () => {
...rest
} = form;
- const thresholds = {
- ...(cpu ? { usage_cpu: usage_cpu / 100 } : {}),
- ...(memory ? { usage_memory: usage_memory / 100 } : {}),
- ...(disk ? { usage_disk: usage_disk / 100 } : {}),
- ...(temperature ? { usage_temperature: usage_temperature / 100 } : {}),
- };
+ // Only build thresholds for hardware monitors
+ const thresholds =
+ monitorType === "hardware"
+ ? {
+ ...(cpu ? { usage_cpu: usage_cpu / 100 } : {}),
+ ...(memory ? { usage_memory: usage_memory / 100 } : {}),
+ ...(disk ? { usage_disk: usage_disk / 100 } : {}),
+ ...(temperature ? { usage_temperature: usage_temperature / 100 } : {}),
+ }
+ : {};
const finalForm = {
...(isCreate ? {} : { _id: monitorId }),
...rest,
description: form.name,
- type: "hardware",
+ type: monitorType,
notifications: infrastructureMonitor.notifications,
- thresholds,
+ ...(Object.keys(thresholds).length > 0 ? { thresholds } : {}),
};
// Handle create or update
isCreate
diff --git a/client/src/Pages/v1/Infrastructure/Create/index.jsx b/client/src/Pages/v1/Infrastructure/Create/index.jsx
index 82cf80c1b..7eb85f758 100644
--- a/client/src/Pages/v1/Infrastructure/Create/index.jsx
+++ b/client/src/Pages/v1/Infrastructure/Create/index.jsx
@@ -63,7 +63,7 @@ const CreateInfrastructureMonitor = () => {
const { buildForm, submitInfrastructureForm, isCreating, isUpdating } =
useInfrastructureSubmit();
- const FREQUENCIES = [
+ const ALL_FREQUENCIES = [
{ _id: 0.25, name: t("time.fifteenSeconds") },
{ _id: 0.5, name: t("time.thirtySeconds") },
{ _id: 1, name: t("time.oneMinute") },
@@ -71,6 +71,12 @@ const CreateInfrastructureMonitor = () => {
{ _id: 5, name: t("time.fiveMinutes") },
{ _id: 10, name: t("time.tenMinutes") },
];
+
+ // Docker monitors require minimum 30 second interval
+ const FREQUENCIES =
+ monitorType === "docker"
+ ? ALL_FREQUENCIES.filter((f) => f._id >= 0.5)
+ : ALL_FREQUENCIES;
const CRUMBS = [
{ name: "Infrastructure monitors", path: "/infrastructure" },
...(isCreate
@@ -102,12 +108,12 @@ const CreateInfrastructureMonitor = () => {
// Handlers
const onSubmit = async (event) => {
event.preventDefault();
- const form = buildForm(infrastructureMonitor, https);
+ const form = buildForm(infrastructureMonitor, https, monitorType);
const error = validateForm(form);
if (error) {
return;
}
- submitInfrastructureForm(infrastructureMonitor, form, isCreate, monitorId);
+ submitInfrastructureForm(infrastructureMonitor, form, isCreate, monitorId, monitorType);
};
const triggerUpdate = () => {
@@ -204,15 +210,25 @@ const CreateInfrastructureMonitor = () => {
{t("settingsGeneralSettings")}
- {t("infrastructureCreateGeneralSettingsDescription")}
+ {monitorType === "docker"
+ ? "Configure your Capture server to monitor Docker containers."
+ : t("infrastructureCreateGeneralSettingsDescription")}
- {t("infrastructureServerRequirement")}{" "}
-
+ {monitorType === "docker" ? (
+ <>
+ Capture server endpoint: /api/v1/metrics/docker
+ >
+ ) : (
+ <>
+ {t("infrastructureServerRequirement")}{" "}
+
+ >
+ )}
@@ -221,8 +237,16 @@ const CreateInfrastructureMonitor = () => {
id="url"
name="url"
startAdornment={}
- placeholder={"localhost:59232/api/v1/metrics"}
- label={t("infrastructureServerUrlLabel")}
+ placeholder={
+ monitorType === "docker"
+ ? "192.168.1.100:59232"
+ : "localhost:59232/api/v1/metrics"
+ }
+ label={
+ monitorType === "docker"
+ ? "Capture Server URL"
+ : t("infrastructureServerUrlLabel")
+ }
https={https}
value={infrastructureMonitor.url}
onChange={onChange}
@@ -268,7 +292,12 @@ const CreateInfrastructureMonitor = () => {
type="text"
id="secret"
name="secret"
- label={t("infrastructureAuthorizationSecretLabel")}
+ label={
+ monitorType === "docker"
+ ? "Capture API Secret"
+ : t("infrastructureAuthorizationSecretLabel")
+ }
+ placeholder={monitorType === "docker" ? "Bearer token for Capture API" : ""}
value={infrastructureMonitor.secret}
onChange={onChange}
error={errors["secret"] ? true : false}
@@ -325,12 +354,14 @@ const CreateInfrastructureMonitor = () => {
/>
-
+ {monitorType === "hardware" && (
+
+ )}
{
+ const theme = useTheme();
+
+ // Helper to format uptime
+ const formatUptime = (startedAt, finishedAt, running) => {
+ if (!running && finishedAt > 0) {
+ const stoppedAgo = Math.floor(Date.now() / 1000) - finishedAt;
+ return formatDuration(stoppedAgo) + " ago";
+ }
+ if (running && startedAt > 0) {
+ const uptimeSeconds = Math.floor(Date.now() / 1000) - startedAt;
+ return formatDuration(uptimeSeconds);
+ }
+ return "N/A";
+ };
+
+ // Helper to format duration
+ const formatDuration = (seconds) => {
+ const days = Math.floor(seconds / 86400);
+ const hours = Math.floor((seconds % 86400) / 3600);
+ const minutes = Math.floor((seconds % 3600) / 60);
+
+ if (days > 0) return `${days}d ${hours}h`;
+ if (hours > 0) return `${hours}h ${minutes}m`;
+ if (minutes > 0) return `${minutes}m`;
+ return `${seconds}s`;
+ };
+
+ // Helper to get status color
+ const getStatusColor = (status, running, healthy) => {
+ if (status === "running" && healthy) return "success";
+ if (status === "running" && !healthy) return "warning";
+ if (status === "exited") return "error";
+ if (status === "paused") return "warning";
+ if (status === "restarting") return "warning";
+ return "default";
+ };
+
+ const headers = [
+ {
+ id: "name",
+ content: "Container Name",
+ render: (row) => (
+
+
+ {row.container_name || "Unnamed"}
+
+
+ {row.container_id ? row.container_id.substring(0, 12) : "N/A"}
+
+
+ ),
+ },
+ {
+ id: "status",
+ content: "Status",
+ render: (row) => (
+
+ ),
+ },
+ {
+ id: "health",
+ content: "Health",
+ render: (row) => (
+
+
+ {row.health?.healthy ? "Healthy" : "Unhealthy"}
+
+
+ {row.health?.source === "container_health_check" ? "HEALTHCHECK" : "State-based"}
+
+
+ ),
+ },
+ {
+ id: "image",
+ content: "Image",
+ render: (row) => (
+ {row.base_image || "N/A"}
+ ),
+ },
+ {
+ id: "uptime",
+ content: "Uptime",
+ render: (row) => (
+
+ {formatUptime(row.started_at, row.finished_at, row.running)}
+
+ ),
+ },
+ {
+ id: "ports",
+ content: "Ports",
+ render: (row) => (
+
+ {row.exposed_ports && row.exposed_ports.length > 0 ? (
+ row.exposed_ports.map((port, idx) => (
+
+ {port.port}/{port.protocol}
+
+ ))
+ ) : (
+
+ None
+
+ )}
+
+ ),
+ },
+ ];
+
+ if (!containers || containers.length === 0) {
+ return (
+
+
+ No containers found
+
+
+ );
+ }
+
+ return (
+
+
+ Docker Containers ({containers.length})
+
+
+
+ );
+};
+
+export default DockerContainersTable;
diff --git a/client/src/Pages/v1/Infrastructure/Details/index.jsx b/client/src/Pages/v1/Infrastructure/Details/index.jsx
index f9c51c27d..03904de99 100644
--- a/client/src/Pages/v1/Infrastructure/Details/index.jsx
+++ b/client/src/Pages/v1/Infrastructure/Details/index.jsx
@@ -8,6 +8,7 @@ import GaugeBoxes from "./Components/GaugeBoxes/index.jsx";
import AreaChartBoxes from "./Components/AreaChartBoxes/index.jsx";
import GenericFallback from "@/Components/v1/GenericFallback/index.jsx";
import NetworkStats from "./Components/NetworkStats/index.jsx";
+import DockerContainersTable from "./Components/DockerContainersTable/index.jsx";
import CustomTabList from "@/Components/v1/Tab/index.jsx";
import TabContext from "@mui/lab/TabContext";
@@ -98,12 +99,25 @@ const InfrastructureDetails = () => {
label={t("details")}
value="details"
/>
-
+ {monitor?.type !== "docker" && (
+
+ )}
- {tab === "details" && (
+ {tab === "details" && monitor?.type === "docker" && (
+ <>
+
+
+ >
+ )}
+ {tab === "details" && monitor?.type !== "docker" && (
<>
{
/>
>
)}
- {tab === "network" && (
+ {tab === "network" && monitor?.type !== "docker" && (