Complete Docker monitoring integration with Capture API

This commit completes the Docker container monitoring feature using Capture API.

Frontend changes:
- Updated Infrastructure create/edit form to support Docker monitors
  - Conditional UI based on monitor type (hardware vs docker)
  - Docker-specific labels and placeholders
  - Capture server URL field (e.g., http://192.168.1.100:59232)
  - API secret field for Bearer token authentication
  - Enforced 30-second minimum polling interval for Docker
  - Conditionally hide hardware thresholds for Docker monitors

- Updated useInfrastructureSubmit hook
  - Accept monitorType parameter (hardware or docker)
  - Build form with type-specific fields
  - Only add thresholds for hardware monitors
  - Submit with correct monitor type to backend

- Created DockerContainersTable component
  - Displays all containers from Capture API response
  - Shows: container name, ID, status, health, image, uptime, ports
  - Color-coded status indicators (green=healthy, yellow=warning, red=error)
  - Formats uptime/downtime duration
  - Handles empty state gracefully

- Updated Infrastructure Details page
  - Conditionally render Docker container table for docker monitors
  - Keep existing hardware metrics (gauges, charts) for hardware monitors
  - Hide network tab for Docker monitors (not applicable)
  - Display container data from latest check

Implementation complete and ready for testing.
This commit is contained in:
Claude committed 2025-11-15 22:33:05 +00:00
1 parent 0f3c81c052
commit 0a90a30045
4 files changed
+284 -51

No files matched your search

@@ -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")}
</Typography>
<Typography component="p">
{t("infrastructureCreateGeneralSettingsDescription")}
{monitorType === "docker"
? "Configure your Capture server to monitor Docker containers."
: t("infrastructureCreateGeneralSettingsDescription")}
</Typography>
<Typography component="p">
{t("infrastructureServerRequirement")}{" "}
<Link
level="primary"
url="https://github.com/bluewave-labs/checkmate-agent"
label={t("common.monitoringAgentName")}
/>
{monitorType === "docker" ? (
<>
Capture server endpoint: <code>/api/v1/metrics/docker</code>
</>
) : (
<>
{t("infrastructureServerRequirement")}{" "}
<Link
level="primary"
url="https://github.com/bluewave-labs/checkmate-agent"
label={t("common.monitoringAgentName")}
/>
</>
)}
</Typography>
</Stack>
<Stack gap={theme.spacing(8)}>
@@ -221,8 +237,16 @@ const CreateInfrastructureMonitor = () => {
id="url"
name="url"
startAdornment={<HttpAdornment https={https} />}
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 = () => {
/>
</Stack>
</ConfigBox>
<CustomAlertsSection
errors={errors}
onChange={onChange}
infrastructureMonitor={infrastructureMonitor}
handleCheckboxChange={handleCheckboxChange}
/>
{monitorType === "hardware" && (
<CustomAlertsSection
errors={errors}
onChange={onChange}
infrastructureMonitor={infrastructureMonitor}
handleCheckboxChange={handleCheckboxChange}
/>
)}
<ConfigBox>
<Box>
<Typography