Merge pull request #4636 from Infisical/ENG-3802

feat(gateway-v2, relays): health check or relays & health alerts
This commit is contained in:
Andre
2025-10-10 16:10:35 -04:00
committed by GitHub
17 changed files with 568 additions and 20 deletions
+1
View File
@@ -6,6 +6,7 @@ export type TRelay = {
identityId: string | null;
name: string;
host: string;
heartbeat: string;
};
export type TDeleteRelayDTO = {
@@ -5,6 +5,7 @@ import {
faCopy,
faDoorClosed,
faEllipsisV,
faInfoCircle,
faMagnifyingGlass,
faSearch,
faTrash
@@ -41,6 +42,25 @@ import { withPermission } from "@app/hoc";
import { usePopUp } from "@app/hooks";
import { useDeleteRelayById, useGetRelays } from "@app/hooks/api/relays";
const RelayHealthStatus = ({ heartbeat }: { heartbeat?: string }) => {
const heartbeatDate = heartbeat ? new Date(heartbeat) : null;
const now = new Date();
const oneHourAgo = new Date(now.getTime() - 60 * 60 * 1000);
const isHealthy = !heartbeatDate || heartbeatDate >= oneHourAgo;
const tooltipContent = heartbeatDate
? `Last heartbeat: ${heartbeatDate.toLocaleString()}`
: "No heartbeat data available";
return (
<Tooltip content={tooltipContent}>
<span className={`cursor-default ${isHealthy ? "text-green-400" : "text-red-400"}`}>
{isHealthy ? "Healthy" : "Unreachable"}
</span>
</Tooltip>
);
};
export const RelayTab = withPermission(
() => {
const [search, setSearch] = useState("");
@@ -106,6 +126,16 @@ export const RelayTab = withPermission(
<Th className="w-1/3">Name</Th>
<Th>Host</Th>
<Th>Created</Th>
<Th>
Health Check
<Tooltip
asChild={false}
className="normal-case"
content="The last known healthcheck. Triggers every 1 hour."
>
<FontAwesomeIcon icon={faInfoCircle} className="ml-2" />
</Tooltip>
</Th>
<Th className="w-5" />
</Tr>
</THead>
@@ -129,6 +159,9 @@ export const RelayTab = withPermission(
</Td>
<Td>{el.host}</Td>
<Td>{formatRelative(new Date(el.createdAt), new Date())}</Td>
<Td>
<RelayHealthStatus heartbeat={el.heartbeat} />
</Td>
<Td className="w-5">
<Tooltip className="max-w-sm text-center" content="Options">
<DropdownMenu>