This commit is contained in:
Alex Holliday committed 2025-12-30 21:47:03 +00:00
1 parent 7a01a8a8a3
commit 8b079905a3
6 files changed
+213 -92

No files matched your search

@@ -0,0 +1,95 @@
import Stack from "@mui/material/Stack";
import Typography from "@mui/material/Typography";
import { BaseChart } from "@/components/monitors/Chart";
import {
ResponsiveContainer,
BarChart,
Bar,
XAxis,
YAxis,
CartesianGrid,
Tooltip,
} from "recharts";
import { XTick } from "@/components/monitors/ChartResponseTime";
import { useTheme } from "@mui/material/styles";
import { BaseBox } from "@/components/design-elements";
import { useAppSelector } from "@/hooks/AppHooks";
import { formatDateWithTz, tooltipDateFormatLookup } from "@/utils/TimeUtils";
type Datum = Record<string, unknown> & { _id: string | number };
export const BarDockerCount = ({
data,
dataKey,
range,
title,
emptyText,
}: {
data: Datum[];
dataKey: string;
range: string;
title: string;
emptyText?: string;
}) => {
const theme = useTheme();
const hasData = Array.isArray(data) && data.length > 0;
const uiTimezone = useAppSelector((state: any) => state.ui.timezone);
const CountTooltip = ({ active, payload, label }: any) => {
if (!active || !payload || !label) return null;
console.log(JSON.stringify(payload, null, 2));
const fmt = tooltipDateFormatLookup(range);
const value = payload?.[0]?.payload?.[dataKey] ?? 0;
return (
<BaseBox sx={{ py: theme.spacing(2), px: theme.spacing(4) }}>
<Typography>
{formatDateWithTz(String(label), fmt, uiTimezone)}
</Typography>
<Typography>Containers: {value}</Typography>
</BaseBox>
);
};
return (
<BaseChart title={title} icon={null}>
{!hasData ? (
<Stack height={"100%"} alignItems={"center"} justifyContent={"center"}>
<Typography variant="h2">{emptyText || "No data"}</Typography>
</Stack>
) : (
<ResponsiveContainer width="100%" height={200}>
<BarChart data={data}>
<defs>
<linearGradient id={"gradient"} x1="0" y1="0" x2="0" y2="1">
<stop
offset="0%"
stopColor={theme.palette.primary.main}
stopOpacity={0.85}
/>
<stop
offset="100%"
stopColor={theme.palette.primary.light}
stopOpacity={0}
/>
</linearGradient>
</defs>
<CartesianGrid
stroke={theme.palette.divider}
strokeWidth={1}
vertical={false}
/>
<XAxis
dataKey={"_id"}
tick={(props) => <XTick {...props} range={range} />}
/>
<YAxis allowDecimals={false} />
<Tooltip content={<CountTooltip />} cursor={false} />
<Bar dataKey={dataKey} fill={`url(#gradient)`} />
</BarChart>
</ResponsiveContainer>
)}
</BaseChart>
);
};
export default BarDockerCount;
+1
View File
@@ -8,3 +8,4 @@ export { HistogramInfrastructure } from "./HistogramInfrastructure";
export { CardDockerContainer } from "./CardDockerContainer";
export { HeaderFilter } from "./HeaderFilter";
export { HistogramDockerPercentage } from "./HistogramDockerPercentage";
export { BarDockerCount } from "./BarDockerCount";
+94 -86
View File
@@ -109,47 +109,46 @@
}
},
"checks": {
"details": {
"common": {
"requestTime": "Total request time: {{time}}"
},
"detailsCard": {
"fields": {
"checkTime": "Check time",
"code": "HTTP Code",
"dns": "DNS",
"download": "Download",
"firstByte": "First byte",
"message": "Message",
"request": "Request",
"status": "Status",
"tcp": "TCP",
"timingPhases": "Timing phases",
"tls": "TLS",
"total": "Total",
"type": "Type",
"wait": "Wait"
},
"headers": {
"basicInfo": "Basic check info",
"timing": "Timing phases"
},
"linkText": "View monitor",
"title": "Check details"
},
"timingChart": {
"title": "Request timings"
}
},
"table": {
"empty": "No checks",
"headers": {
"dateTime": "Date & Time",
"statusCode": "Status code"
}
},
"details": {
"common": {
"requestTime": "Total request time: {{time}}"
},
"detailsCard": {
"title": "Check details",
"linkText": "View monitor",
"headers": {
"basicInfo": "Basic check info",
"timing": "Timing phases"
},
"fields": {
"status": "Status",
"code": "HTTP Code",
"type": "Type",
"checkTime": "Check time",
"message": "Message",
"timingPhases": "Timing phases",
"wait": "Wait",
"dns": "DNS",
"tcp": "TCP",
"tls": "TLS",
"request": "Request",
"firstByte": "First byte",
"download": "Download",
"total": "Total"
}
},
"timingChart": {
"title": "Request timings"
}
}
},
"common": {
"appName": "Checkmate",
"breadcrumbs": {
@@ -158,6 +157,7 @@
"configure": "Configure",
"create": "Create",
"diagnostics": "Diagnostics",
"docker": "Docker Monitors",
"incidents": "Incidents",
"infrastructure": "Infrastructure Monitors",
"invite": "Invite",
@@ -181,11 +181,11 @@
"disable": "Disable",
"enable": "Enable",
"exportJson": "Export to JSON",
"home": "Return home",
"importJson": "Import from JSON",
"incidents": "Incidents",
"limitReached": "Your plan's limit has been reached",
"no": "No",
"home": "Return home",
"pause": "Pause",
"range": {
"all": "All",
@@ -240,12 +240,12 @@
"weight": "Weight"
},
"uptime": {
"avgResponseTime": "Avg response time",
"detail": "Total checks",
"downTitle": "Downtime",
"emptyDown": "Great, no downtime!",
"emptyUp": "No checks yet",
"upTitle": "Uptime",
"avgResponseTime": "Avg response time"
"upTitle": "Uptime"
}
},
"dialog": {
@@ -259,11 +259,11 @@
"headers": {
"actions": "Actions",
"active": "Active",
"message": "Message",
"monitor": "Monitor",
"name": "Name",
"status": "Status",
"type": "Type",
"message": "Message"
"type": "Type"
}
},
"toasts": {
@@ -280,30 +280,20 @@
},
"diagnostics": {
"infoBox": {
"title": "System Diagnostics",
"description": "Review system logs and background job status to troubleshoot issues. Monitor the health of your monitoring infrastructure and investigate any problems."
},
"tabs": {
"logs": "Logs",
"queue": "Queue",
"config": "Config",
"access": "Access"
"description": "Review system logs and background job status to troubleshoot issues. Monitor the health of your monitoring infrastructure and investigate any problems.",
"title": "System Diagnostics"
},
"logs": {
"table": {
"headers": {
"timestamp": "Timestamp",
"level": "Level",
"service": "Service"
"service": "Service",
"timestamp": "Timestamp"
}
}
},
"queue": {
"stats": {
"monitoringJobs": {
"title": "Monitoring jobs",
"tooltip": "Total number of monitoring jobs in the queue"
},
"activeJobs": {
"title": "Active jobs",
"tooltip": "Number of jobs being processed"
@@ -312,27 +302,37 @@
"title": "Failing jobs",
"tooltip": "Jobs that failed on their last execution"
},
"totalRuns": {
"title": "Total runs",
"tooltip": "Total number of job executions"
"monitoringJobs": {
"title": "Monitoring jobs",
"tooltip": "Total number of monitoring jobs in the queue"
},
"totalFailures": {
"title": "Total failures",
"tooltip": "Total number of failed job executions"
},
"totalRuns": {
"title": "Total runs",
"tooltip": "Total number of job executions"
}
},
"table": {
"headers": {
"jobId": "Job ID",
"url": "URL",
"interval": "Interval",
"runs": "Runs",
"lastRun": "Last run",
"lockedAt": "Locked at",
"finishedAt": "Finished at",
"lastRunTook": "Last run took (ms)"
"interval": "Interval",
"jobId": "Job ID",
"lastRun": "Last run",
"lastRunTook": "Last run took (ms)",
"lockedAt": "Locked at",
"runs": "Runs",
"url": "URL"
}
}
},
"tabs": {
"access": "Access",
"config": "Config",
"logs": "Logs",
"queue": "Queue"
}
},
"export": {
@@ -517,6 +517,38 @@
}
},
"docker": {
"details": {
"dockerContainerCard": {
"fields": {
"health": "Health",
"id": "ID",
"image": "Image",
"ports": "Ports",
"status": "Status"
},
"title": "Container: {{name}}",
"values": {
"healthy": "Healthy",
"unhealthy": "Unhealthy"
}
},
"healthyChart": {
"empty": "No data",
"title": "Healthy container %"
},
"healthyCountChart": {
"empty": "No data",
"title": "# of healthy containers"
},
"runningChart": {
"empty": "No data",
"title": "Running container %"
},
"runningCountChart": {
"empty": "No data",
"title": "# of running containers"
}
},
"fallback": {
"actionButton": "Create a monitor!",
"checks": [
@@ -531,30 +563,6 @@
"headers": {
"runningContainers": "Running containers"
}
},
"details": {
"dockerContainerCard": {
"title": "Container: {{name}}",
"fields": {
"status": "Status",
"health": "Health",
"id": "ID",
"image": "Image",
"ports": "Ports"
},
"values": {
"healthy": "Healthy",
"unhealthy": "Unhealthy"
}
},
"healthyChart": {
"title": "Healthy container %",
"empty": "No data"
},
"runningChart": {
"title": "Running container %",
"empty": "No data"
}
}
},
"infrastructure": {
+18 -3
View File
@@ -2,6 +2,7 @@ import { BasePage, StatBox } from "@/components/design-elements";
import {
HeaderControls,
HeaderRange,
BarDockerCount,
HistogramDockerPercentage,
} from "@/components/monitors";
import Stack from "@mui/material/Stack";
@@ -38,7 +39,7 @@ const DockerDetailsPage = () => {
const monitor = response?.data?.monitor;
const stats = response?.data?.stats;
const checks = (response?.data?.checks || []) as any;
const snapshot = monitor?.latestChecks?.[0].containerSnapshot || [];
const snapshot = monitor?.latestChecks?.[0].dockerContainers || [];
const palette = getStatusPalette(monitor?.status || "initializing");
const streakDuration = stats?.currentStreakStartedAt
@@ -85,6 +86,20 @@ const DockerDetailsPage = () => {
<CardDockerContainer key={c.container_id} container={c} />
))}
</Stack>
<BarDockerCount
data={checks}
dataKey="healthyContainers"
range={range}
title={t("monitors.docker.details.healthyCountChart.title")}
emptyText={t("monitors.docker.details.healthyCountChart.empty")}
/>
<BarDockerCount
data={checks}
dataKey="runningContainers"
range={range}
title={t("monitors.docker.details.runningCountChart.title")}
emptyText={t("monitors.docker.details.runningCountChart.empty")}
/>
<HistogramDockerPercentage
data={checks}
dataKey="healthyPercent"
@@ -96,8 +111,8 @@ const DockerDetailsPage = () => {
data={checks}
dataKey="runningPercent"
range={range}
title={t("monitors.docker.details.runningChart.title")}
emptyText={t("monitors.docker.details.runningChart.empty")}
title={t("monitors.docker.details.healthyChart.title")}
emptyText={t("monitors.docker.details.healthyChart.empty")}
/>
</BasePage>
);
@@ -116,8 +116,10 @@ export const DockerMonitorsTable = ({
</Typography>
),
render: (row) => {
const containerCount = (row.latestChecks?.[0]?.dockerContainers || [])
.length;
console.log(row);
const containerCount = (
row.latestChecks?.[0]?.dockerContainers || []
).filter((c: any) => c?.running).length;
return containerCount;
},
},
+1 -1
View File
@@ -123,7 +123,7 @@ export interface ICheck {
lighthouse?: ICheckLighthouseFields;
system?: ISystemInfo;
// Present for docker monitor checks
containerSnapshot?: IDockerContainerSummary[];
dockerContainers?: IDockerContainerSummary[];
}
export interface CheckWithMonitor {
_id: string;