add DNS monitor to create monitor form

This commit is contained in:
Alex committed 2026-05-11 10:01:23 -07:00
1 parent 427f8c632f
commit 98d2bbfbb9
4 files changed
+139 -4

No files matched your search

+9
View File
@@ -111,6 +111,15 @@ export const useMonitorForm = ({
ignoreTlsErrors: data?.ignoreTlsErrors || false, ignoreTlsErrors: data?.ignoreTlsErrors || false,
}; };
break; break;
case "dns":
defaults = {
...base,
type: "dns",
url: data?.url || "",
dnsServer: data?.dnsServer || "",
dnsRecordType: data?.dnsRecordType || "A",
};
break;
default: default:
defaults = { defaults = {
...base, ...base,
+109 -1
View File
@@ -51,6 +51,8 @@ interface GeneralSettingsConfig {
showSecret: boolean; showSecret: boolean;
showGrpcServiceName: boolean; showGrpcServiceName: boolean;
showIgnoreTls: boolean; showIgnoreTls: boolean;
showDnsServer: boolean;
showDnsRecordType: boolean;
} }
const getGeneralSettingsConfig = ( const getGeneralSettingsConfig = (
@@ -68,6 +70,8 @@ const getGeneralSettingsConfig = (
showSecret: false, showSecret: false,
showGrpcServiceName: false, showGrpcServiceName: false,
showIgnoreTls: false, showIgnoreTls: false,
showDnsServer: false,
showDnsRecordType: false,
}, },
ping: { ping: {
urlLabel: t("pages.createMonitor.form.general.option.host.label"), urlLabel: t("pages.createMonitor.form.general.option.host.label"),
@@ -79,6 +83,8 @@ const getGeneralSettingsConfig = (
showSecret: false, showSecret: false,
showGrpcServiceName: false, showGrpcServiceName: false,
showIgnoreTls: false, showIgnoreTls: false,
showDnsServer: false,
showDnsRecordType: false,
}, },
docker: { docker: {
urlLabel: t("pages.createMonitor.form.general.option.container.label"), urlLabel: t("pages.createMonitor.form.general.option.container.label"),
@@ -90,6 +96,8 @@ const getGeneralSettingsConfig = (
showSecret: false, showSecret: false,
showGrpcServiceName: false, showGrpcServiceName: false,
showIgnoreTls: false, showIgnoreTls: false,
showDnsServer: false,
showDnsRecordType: false,
}, },
port: { port: {
urlLabel: t("pages.createMonitor.form.general.option.url.label"), urlLabel: t("pages.createMonitor.form.general.option.url.label"),
@@ -101,6 +109,8 @@ const getGeneralSettingsConfig = (
showSecret: false, showSecret: false,
showGrpcServiceName: false, showGrpcServiceName: false,
showIgnoreTls: false, showIgnoreTls: false,
showDnsServer: false,
showDnsRecordType: false,
}, },
game: { game: {
urlLabel: t("pages.createMonitor.form.general.option.url.label"), urlLabel: t("pages.createMonitor.form.general.option.url.label"),
@@ -112,6 +122,8 @@ const getGeneralSettingsConfig = (
showSecret: false, showSecret: false,
showGrpcServiceName: false, showGrpcServiceName: false,
showIgnoreTls: false, showIgnoreTls: false,
showDnsServer: false,
showDnsRecordType: false,
}, },
grpc: { grpc: {
urlLabel: t("pages.createMonitor.form.general.option.host.label"), urlLabel: t("pages.createMonitor.form.general.option.host.label"),
@@ -123,6 +135,8 @@ const getGeneralSettingsConfig = (
showSecret: false, showSecret: false,
showGrpcServiceName: true, showGrpcServiceName: true,
showIgnoreTls: true, showIgnoreTls: true,
showDnsServer: false,
showDnsRecordType: false,
}, },
pagespeed: { pagespeed: {
urlLabel: t("pages.createMonitor.form.general.option.url.label"), urlLabel: t("pages.createMonitor.form.general.option.url.label"),
@@ -134,6 +148,8 @@ const getGeneralSettingsConfig = (
showSecret: false, showSecret: false,
showGrpcServiceName: false, showGrpcServiceName: false,
showIgnoreTls: false, showIgnoreTls: false,
showDnsServer: false,
showDnsRecordType: false,
}, },
hardware: { hardware: {
urlLabel: t("pages.createMonitor.form.general.option.captureUrl.label"), urlLabel: t("pages.createMonitor.form.general.option.captureUrl.label"),
@@ -145,6 +161,8 @@ const getGeneralSettingsConfig = (
showSecret: true, showSecret: true,
showGrpcServiceName: false, showGrpcServiceName: false,
showIgnoreTls: false, showIgnoreTls: false,
showDnsServer: false,
showDnsRecordType: false,
}, },
websocket: { websocket: {
urlLabel: t("pages.createMonitor.form.general.option.wsUrl.label"), urlLabel: t("pages.createMonitor.form.general.option.wsUrl.label"),
@@ -156,6 +174,21 @@ const getGeneralSettingsConfig = (
showSecret: false, showSecret: false,
showGrpcServiceName: false, showGrpcServiceName: false,
showIgnoreTls: true, 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; return configs[type] || configs.http;
@@ -349,6 +382,13 @@ const CreateMonitorPage = () => {
"pages.createMonitor.form.type.optionWebSocketDescription" "pages.createMonitor.form.type.optionWebSocketDescription"
)} )}
/> />
<RadioWithDescription
value="dns"
label={t("pages.common.monitors.monitorTypes.optionDns")}
description={t(
"pages.createMonitor.form.type.optionDnsDescription"
)}
/>
</RadioGroup> </RadioGroup>
</FormControl> </FormControl>
)} )}
@@ -495,6 +535,74 @@ const CreateMonitorPage = () => {
)} )}
/> />
)} )}
{generalSettingsConfig.showDnsServer && (
<Controller
name="dnsServer"
control={control}
render={({ field, fieldState }) => (
<TextField
{...field}
value={field.value ?? ""}
type="text"
fieldLabel={t(
"pages.createMonitor.form.general.option.dnsServer.label"
)}
placeholder={t(
"pages.createMonitor.form.general.option.dnsServer.placeholder"
)}
fullWidth
error={!!fieldState.error}
helperText={fieldState.error?.message ?? ""}
/>
)}
/>
)}
{generalSettingsConfig.showDnsRecordType && (
<Controller
name="dnsRecordType"
control={control}
defaultValue="A"
render={({ field, fieldState }) => (
<Select
{...field}
value={field.value ?? "A"}
fieldLabel={t(
"pages.createMonitor.form.general.option.dnsRecordType.label"
)}
error={!!fieldState.error}
>
<MenuItem value={"A"}>
{t("pages.createMonitor.form.general.option.dnsRecordType.value.A")}
</MenuItem>
<MenuItem value={"AAAA"}>
{t(
"pages.createMonitor.form.general.option.dnsRecordType.value.AAAA"
)}
</MenuItem>
<MenuItem value={"CNAME"}>
{t(
"pages.createMonitor.form.general.option.dnsRecordType.value.CNAME"
)}
</MenuItem>
<MenuItem value={"MX"}>
{t(
"pages.createMonitor.form.general.option.dnsRecordType.value.MX"
)}
</MenuItem>
<MenuItem value={"NS"}>
{t(
"pages.createMonitor.form.general.option.dnsRecordType.value.NS"
)}
</MenuItem>
<MenuItem value={"TXT"}>
{t(
"pages.createMonitor.form.general.option.dnsRecordType.value.TXT"
)}
</MenuItem>
</Select>
)}
/>
)}
<Controller <Controller
name="name" name="name"
@@ -900,7 +1008,7 @@ const CreateMonitorPage = () => {
/> />
<Typography <Typography
component="span" component="span"
color="text.secondary" color={theme.palette.text.secondary}
sx={{ opacity: 0.8 }} sx={{ opacity: 0.8 }}
> >
<Trans <Trans
+1 -1
View File
@@ -77,7 +77,7 @@ const UptimeMonitorsPage = () => {
const effectiveTypes = const effectiveTypes =
selectedTypes.length > 0 selectedTypes.length > 0
? selectedTypes ? selectedTypes
: ["http", "ping", "docker", "port", "game", "grpc", "websocket"]; : ["http", "ping", "docker", "port", "game", "grpc", "websocket", "dns"];
// Build URL for monitors with checks // Build URL for monitors with checks
const monitorsWithChecksUrl = useMemo(() => { const monitorsWithChecksUrl = useMemo(() => {
+20 -2
View File
@@ -475,7 +475,8 @@
"optionPagespeed": "PageSpeed", "optionPagespeed": "PageSpeed",
"optionHardware": "Infrastructure", "optionHardware": "Infrastructure",
"optionGrpc": "gRPC", "optionGrpc": "gRPC",
"optionWebSocket": "WebSocket" "optionWebSocket": "WebSocket",
"optionDns": "DNS"
} }
} }
}, },
@@ -565,6 +566,21 @@
"captureUrl": { "captureUrl": {
"label": "Capture endpoint", "label": "Capture endpoint",
"placeholder": "http://192.168.1.10:5001/api/v1/metrics" "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", "title": "General settings",
@@ -577,7 +593,8 @@
"pagespeed": "Track page load performance, Core Web Vitals, and optimization scores for your website.", "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.", "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.", "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": { "ignoreTls": {
@@ -614,6 +631,7 @@
"optionHttpDescription": "Use HTTP(S) to monitor your website or API endpoint.", "optionHttpDescription": "Use HTTP(S) to monitor your website or API endpoint.",
"optionPingDescription": "Use ICMP Ping to monitor if a server is online.", "optionPingDescription": "Use ICMP Ping to monitor if a server is online.",
"optionPortDescription": "Monitor if a specific port on a server is open.", "optionPortDescription": "Monitor if a specific port on a server is open.",
"optionDnsDescription": "Monitor if a specific DNS server is responding.",
"title": "Type" "title": "Type"
}, },
"thresholds": { "thresholds": {