Skip to content

Dns addition in monitor#3449

Open
Owaiseimdad wants to merge 4 commits intobluewave-labs:developfrom
Owaiseimdad:DNS-Addition-In-Monitor
Open

Dns addition in monitor#3449
Owaiseimdad wants to merge 4 commits intobluewave-labs:developfrom
Owaiseimdad:DNS-Addition-In-Monitor

Conversation

@Owaiseimdad
Copy link
Copy Markdown
Contributor

Describe your changes

Implemented a new DNS Monitor type to allow users to track domain resolution success and query latency. Key changes include:
Core Logic: Created DnsProvider.ts using Node's dns/promises API. It supports configurable DNS servers and multiple record types (A, AAAA, CNAME, MX, TXT, NS).

Backend Persistence:
Updated the Mongoose Monitor schema to include dnsServer and dnsRecordType.
Updated both MongoMonitorsRepository and TimescaleMonitorsRepository to ensure DNS configuration persists across both database types. Updated MonitorService to support fetching uptime details for the new DNS type.

Validation: Refactored the backend validation to use the centralized MonitorTypes constant in monitorValidation.ts and checkValidation.ts, resolving Zod validation errors for the new type.

Frontend UI:
Added DNS-specific fields (DNS Server, Record Type) to the CreateMonitorPage.
Updated the monitor list and ControlsFilter to include DNS monitors by default.
Improved UI consistency by rounding both Average and Maximum latency values to the nearest millisecond in
HistogramResponseTime.tsx.

i18n: Added comprehensive English translations for all new DNS-related labels and descriptions in en.json
.

Write your issue number after "Fixes "

#3388

Please ensure all items are checked off before requesting a review. "Checked off" means you need to add an "x" character between brackets so they turn into checkmarks.

  • (Do not skip this or your PR will be closed) I deployed the application locally.
  • (Do not skip this or your PR will be closed) I have performed a self-review and testing of my code.
  • I have included the issue # in the PR.
  • I have added i18n support to visible strings (instead of <div>Add</div>, use):
const { t } = useTranslation();
<div>{t('add')}</div>
  • I have not included any files that are not related to my pull request, including package-lock and package-json if dependencies have not changed
  • I didn't use any hardcoded values (otherwise it will not scale, and will make it difficult to maintain consistency across the application).
  • I made sure font sizes, color choices etc are all referenced from the theme. I don't have any hardcoded dimensions.
  • My PR is granular and targeted to one specific feature.
  • I ran npm run format in server and client directories, which automatically formats your code.
  • I took a screenshot or a video and attached to this PR if there is a UI change.
Screenshot 2026-03-29 at 10 56 05 PM Screenshot 2026-03-29 at 10 56 19 PM

@ajhollid
Copy link
Copy Markdown
Collaborator

Hey @Owaiseimdad,

Let's split this up into two PRs please, one for frontend and one for backend.

We'll review backend functionality for correctness first, then we can look at the UI side of of things.

Thanks!

@Br0wnHammer Br0wnHammer added the enhancement New feature or request label Mar 30, 2026
@Br0wnHammer Br0wnHammer added this to the 3.5 milestone Mar 30, 2026
@Owaiseimdad
Copy link
Copy Markdown
Contributor Author

Hey @Owaiseimdad,

Let's split this up into two PRs please, one for frontend and one for backend.

We'll review backend functionality for correctness first, then we can look at the UI side of of things.

Thanks!

I have added only backend now and after this will raise a UI related code.

Copy link
Copy Markdown
Member

@Br0wnHammer Br0wnHammer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @Owaiseimdad , nice work adding DNS monitoring support. I left a few comments on DnsProvider.ts. Please take a look.

import { Monitor, MonitorType } from "@/types/monitor.js";
import { NETWORK_ERROR } from "@/service/infrastructure/network/utils.js";

export class DnsProvider implements IStatusProvider<DnsStatusPayload> {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DnsProvider doesn't follow the project's dependency injection pattern. DnsProvider directly imports Resolver from dns/promises and instantiates it inside handle().

throw new Error("Hostname is required for DNS monitor");
}

const resolver = new Resolver();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other providers enforce a timeout (e.g. TIMEOUT_MS = 10000) and DNS queries can hang indefinitely without one.

resolver.setServers([dnsServer]);
}

const startTime = process.hrtime();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other providers use the shared timeRequest helper from utils.js instead of manually calling hrtime()

return type === "dns";
}

async handle(monitor: Monitor): Promise<MonitorStatusResponse<DnsStatusPayload>> {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The entire method body needs an outer try/catch that wraps unexpected errors in AppError (with service, method, details), matching the pattern in WebSocketProvider and GrpcProvider.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants