From 98d2bbfbb9d3d08b1b9f051e56b42aa928b2689a Mon Sep 17 00:00:00 2001 From: Alex Date: Mon, 11 May 2026 10:01:23 -0700 Subject: [PATCH] add DNS monitor to create monitor form --- client/src/Hooks/useMonitorForm.ts | 9 ++ client/src/Pages/CreateMonitor/index.tsx | 110 ++++++++++++++++++++- client/src/Pages/Uptime/Monitors/index.tsx | 2 +- client/src/locales/en.json | 22 ++++- 4 files changed, 139 insertions(+), 4 deletions(-) diff --git a/client/src/Hooks/useMonitorForm.ts b/client/src/Hooks/useMonitorForm.ts index 963409fc8..f202b355e 100644 --- a/client/src/Hooks/useMonitorForm.ts +++ b/client/src/Hooks/useMonitorForm.ts @@ -111,6 +111,15 @@ export const useMonitorForm = ({ ignoreTlsErrors: data?.ignoreTlsErrors || false, }; break; + case "dns": + defaults = { + ...base, + type: "dns", + url: data?.url || "", + dnsServer: data?.dnsServer || "", + dnsRecordType: data?.dnsRecordType || "A", + }; + break; default: defaults = { ...base, diff --git a/client/src/Pages/CreateMonitor/index.tsx b/client/src/Pages/CreateMonitor/index.tsx index 4ae518caa..036ef929e 100644 --- a/client/src/Pages/CreateMonitor/index.tsx +++ b/client/src/Pages/CreateMonitor/index.tsx @@ -51,6 +51,8 @@ interface GeneralSettingsConfig { showSecret: boolean; showGrpcServiceName: boolean; showIgnoreTls: boolean; + showDnsServer: boolean; + showDnsRecordType: boolean; } const getGeneralSettingsConfig = ( @@ -68,6 +70,8 @@ const getGeneralSettingsConfig = ( showSecret: false, showGrpcServiceName: false, showIgnoreTls: false, + showDnsServer: false, + showDnsRecordType: false, }, ping: { urlLabel: t("pages.createMonitor.form.general.option.host.label"), @@ -79,6 +83,8 @@ const getGeneralSettingsConfig = ( showSecret: false, showGrpcServiceName: false, showIgnoreTls: false, + showDnsServer: false, + showDnsRecordType: false, }, docker: { urlLabel: t("pages.createMonitor.form.general.option.container.label"), @@ -90,6 +96,8 @@ const getGeneralSettingsConfig = ( showSecret: false, showGrpcServiceName: false, showIgnoreTls: false, + showDnsServer: false, + showDnsRecordType: false, }, port: { urlLabel: t("pages.createMonitor.form.general.option.url.label"), @@ -101,6 +109,8 @@ const getGeneralSettingsConfig = ( showSecret: false, showGrpcServiceName: false, showIgnoreTls: false, + showDnsServer: false, + showDnsRecordType: false, }, game: { urlLabel: t("pages.createMonitor.form.general.option.url.label"), @@ -112,6 +122,8 @@ const getGeneralSettingsConfig = ( showSecret: false, showGrpcServiceName: false, showIgnoreTls: false, + showDnsServer: false, + showDnsRecordType: false, }, grpc: { urlLabel: t("pages.createMonitor.form.general.option.host.label"), @@ -123,6 +135,8 @@ const getGeneralSettingsConfig = ( showSecret: false, showGrpcServiceName: true, showIgnoreTls: true, + showDnsServer: false, + showDnsRecordType: false, }, pagespeed: { urlLabel: t("pages.createMonitor.form.general.option.url.label"), @@ -134,6 +148,8 @@ const getGeneralSettingsConfig = ( showSecret: false, showGrpcServiceName: false, showIgnoreTls: false, + showDnsServer: false, + showDnsRecordType: false, }, hardware: { urlLabel: t("pages.createMonitor.form.general.option.captureUrl.label"), @@ -145,6 +161,8 @@ const getGeneralSettingsConfig = ( showSecret: true, showGrpcServiceName: false, showIgnoreTls: false, + showDnsServer: false, + showDnsRecordType: false, }, websocket: { urlLabel: t("pages.createMonitor.form.general.option.wsUrl.label"), @@ -156,6 +174,21 @@ const getGeneralSettingsConfig = ( showSecret: false, showGrpcServiceName: false, showIgnoreTls: true, + showDnsServer: false, + showDnsRecordType: false, + }, + dns: { + urlLabel: t("pages.createMonitor.form.general.option.url.label"), + urlPlaceholder: t("pages.createMonitor.form.general.option.url.placeholder"), + namePlaceholder: t("pages.createMonitor.form.general.option.name.placeholder"), + showUrl: true, + showPort: false, + showGameSelect: false, + showSecret: false, + showGrpcServiceName: false, + showIgnoreTls: false, + showDnsServer: true, + showDnsRecordType: true, }, }; return configs[type] || configs.http; @@ -349,6 +382,13 @@ const CreateMonitorPage = () => { "pages.createMonitor.form.type.optionWebSocketDescription" )} /> + )} @@ -495,6 +535,74 @@ const CreateMonitorPage = () => { )} /> )} + {generalSettingsConfig.showDnsServer && ( + ( + + )} + /> + )} + {generalSettingsConfig.showDnsRecordType && ( + ( + + )} + /> + )} { /> { const effectiveTypes = selectedTypes.length > 0 ? selectedTypes - : ["http", "ping", "docker", "port", "game", "grpc", "websocket"]; + : ["http", "ping", "docker", "port", "game", "grpc", "websocket", "dns"]; // Build URL for monitors with checks const monitorsWithChecksUrl = useMemo(() => { diff --git a/client/src/locales/en.json b/client/src/locales/en.json index 587e25df1..53ea095f1 100644 --- a/client/src/locales/en.json +++ b/client/src/locales/en.json @@ -475,7 +475,8 @@ "optionPagespeed": "PageSpeed", "optionHardware": "Infrastructure", "optionGrpc": "gRPC", - "optionWebSocket": "WebSocket" + "optionWebSocket": "WebSocket", + "optionDns": "DNS" } } }, @@ -565,6 +566,21 @@ "captureUrl": { "label": "Capture endpoint", "placeholder": "http://192.168.1.10:5001/api/v1/metrics" + }, + "dnsServer": { + "label": "DNS server", + "placeholder": "8.8.8.8" + }, + "dnsRecordType": { + "label": "DNS Record Type", + "value": { + "A": "A", + "AAAA": "AAAA", + "CNAME": "CNAME", + "MX": "MX", + "NS": "NS", + "TXT": "TXT" + } } }, "title": "General settings", @@ -577,7 +593,8 @@ "pagespeed": "Track page load performance, Core Web Vitals, and optimization scores for your website.", "grpc": "Enter the hostname and port of the gRPC server, optionally specify a service name for the health check, and add a display name.", "websocket": "Enter the WebSocket URL to monitor (e.g., wss://example.com/socket) and add a display name.", - "hardware": "Monitor CPU, memory, disk usage, and temperature for your infrastructure. The Capture endpoint URL must include the full path /api/v1/metrics (e.g. http://192.168.1.10:5001/api/v1/metrics). For the authorization secret, paste only the token string — don't include 'Bearer'." + "hardware": "Monitor CPU, memory, disk usage, and temperature for your infrastructure. The Capture endpoint URL must include the full path /api/v1/metrics (e.g. http://192.168.1.10:5001/api/v1/metrics). For the authorization secret, paste only the token string — don't include 'Bearer'.", + "dns": "Monitor if a specific DNS server is responding." } }, "ignoreTls": { @@ -614,6 +631,7 @@ "optionHttpDescription": "Use HTTP(S) to monitor your website or API endpoint.", "optionPingDescription": "Use ICMP Ping to monitor if a server is online.", "optionPortDescription": "Monitor if a specific port on a server is open.", + "optionDnsDescription": "Monitor if a specific DNS server is responding.", "title": "Type" }, "thresholds": {