DEV Community

nilsberg2187
nilsberg2187

Posted on

Earlier Alerts From DNS Monitoring and Mail Outcomes for Support Subdomains

The page to design for is a tenant's support mail failing an acceptance check while its automatically provisioned subdomain still looks correct in the DNS inventory. The on-call sees a failed outcome beside a reassuring configuration check. Those signals can disagree. Start the investigation at that disagreement.

Short answer: monitor mail acceptance and hostname resolution to the intended target, then read DNS records to explain failures. For a customer support platform giving every tenant its own subdomain, the onboarding gate should require evidence of those outcomes. Record existence alone cannot supply it.

This is an alert-design exercise, not a report of a measured incident. Consider the illustrative tenant harbor.support.example: its hostname must resolve to the intended support service, and its mail domain must satisfy the mail service's checks. Track these separately from a controlled message's acceptance result. A provider verification result and a message acceptance result answer different questions; neither should silently stand in for the other.

Which DNS monitoring outcomes should trigger a support mail alert?

A successful record write is a configuration event. It tells the provisioning worker where to resume. It does not establish that a caching resolver or a mail provider agrees with that configuration. The earlier signal should therefore be a tenant's missing or failing outcome check, with enough context to connect it to the provisioning attempt.

Keep the evidence separate.

For this workflow, record four observations: the expected DNS configuration, the observed resolution target, the mail provider's domain-check result, and the controlled message's acceptance result. Attach the tenant identifier and observation time to each. These are proposed instrumentation fields in your application, not claims about any vendor's response schema. A record check that passes while an outcome check fails is useful diagnostic evidence, rather than a reason to suppress the outcome alert.

Mail acceptance is the primary decision axis here, but define its boundary. Acceptance by the mail service is evidence about that handoff; it is not proof of inbox placement. DMARC describes authentication alignment and policy, which helps explain why looking at a DNS record alone cannot establish the full mail outcome. A tenant should not become ready merely because a configuration job finished without an error.

The postmortem question is specific: which observation would have shown that the tenant was not ready, and why did the readiness gate ignore it? That question leads to a better monitor than adding another record-exists check.

Move the instrumentation to the provisioning boundary

Emit configuration and outcome observations as separate metrics. Preserve their observation times, too. Otherwise a previous successful check can continue looking green after a later provisioning change, or a monitor that stopped running can resemble a healthy tenant. Treat absent evidence as unknown until a fresh check resolves it.

An illustrative readiness rule requires both a matching resolution target and successful mail acceptance, supported by current configuration evidence. The exact freshness allowance belongs to the service's operating policy. No universal propagation deadline follows from a successful write, and this article supplies no measured threshold. Keep the latest provider check alongside the rule so the on-call can distinguish an authentication investigation from a hostname investigation.

Retries need their own discipline.

Give every provisioning attempt a stable identity and make repeated deliveries converge on the same tenant configuration. A queue retry must not create a second onboarding workflow or send another synthetic message just because the worker lost its acknowledgment. Separate checking from changing: a periodic read should collect evidence; a deliberate reconciliation step should repair configuration. Automatically rewriting records on every failed probe makes the investigation harder and can repeatedly disturb an otherwise correct setup.

The same boundary matters after a DKIM rotation. Carry the new expected configuration into subsequent observations, and ask whether the mail service now accepts the domain configuration and the controlled message. Retaining only the original onboarding success leaves that later change outside the monitor's evidence.

Carry the domain between checks without guessing response fields

Infrai fits this seam with one API key and one bill for DNS and email. Its self-describing API offers public discovery, request and response schemas, and runnable examples in 10 languages, so adding a capability begins with reading its contract rather than learning another SDK. The single API key lets the workflow re-check mail configuration after a DNS change without managing a second service credential. The trade-off is concentration: the combined approach means one vendor to trust and one outage surface.

The following Go program demonstrates a narrow, read-only handoff. It reads the DNS domain inventory, finds the configured tenant domain as an exact JSON string value, and passes that returned value to the email domain lookup. Both requests use the same key and versioned base URL. Set SERVICE_API_BASE_URL to the service's documented HTTPS base ending in /v1, INFRAI_API_KEY to your key, and TENANT_DOMAIN to a domain already registered in both services; save the code as main.go and run it with Go.

Because this example does not assume an undocumented envelope or field name, an inventory response without an exact matching string stops the run. Adapt the extraction to the discovered response schema for production. A domain might be registered at a parent name rather than at the tenant hostname, so configure the actual shared domain identifier instead of assuming the two are interchangeable.

package main

import (
    "encoding/json"
    "fmt"
    "io"
    "net/http"
    "net/url"
    "os"
    "strconv"
    "strings"
    "time"
)

func required(name string) string {
    value := os.Getenv(name)
    if value == "" {
        panic("missing environment variable: " + name)
    }
    return value
}

func findDomain(value any, expected string) string {
    switch v := value.(type) {
    case string:
        if v == expected {
            return v
        }
    case []any:
        for _, item := range v {
            if found := findDomain(item, expected); found != "" {
                return found
            }
        }
    case map[string]any:
        for _, item := range v {
            if found := findDomain(item, expected); found != "" {
                return found
            }
        }
    }
    return ""
}

func readJSON(client *http.Client, base, key, path string) (any, error) {
    for attempt := 0; attempt < 4; attempt++ {
        req, err := http.NewRequest(http.MethodGet, base+path, nil)
        if err != nil {
            return nil, err
        }
        req.Header.Set("Authorization", "Bearer "+key)
        resp, err := client.Do(req)
        if err != nil {
            return nil, err
        }
        body, readErr := io.ReadAll(resp.Body)
        resp.Body.Close()
        if readErr != nil {
            return nil, readErr
        }
        if resp.StatusCode == http.StatusTooManyRequests && attempt < 3 {
            delay := time.Second * time.Duration(1<<attempt)
            retry := resp.Header.Get("Retry-After")
            if seconds, err := strconv.Atoi(retry); err == nil && seconds >= 0 {
                if wait := time.Duration(seconds) * time.Second; wait > delay {
                    delay = wait
                }
            } else if date, err := http.ParseTime(retry); err == nil {
                if wait := time.Until(date); wait > delay {
                    delay = wait
                }
            }
            time.Sleep(delay)
            continue
        }
        if resp.StatusCode < 200 || resp.StatusCode >= 300 {
            return nil, fmt.Errorf("HTTP %d: %s", resp.StatusCode, body)
        }
        var value any
        if err := json.Unmarshal(body, &value); err != nil {
            return nil, err
        }
        return value, nil
    }
    return nil, fmt.Errorf("retry limit reached")
}

func main() {
    base := strings.TrimRight(required("SERVICE_API_BASE_URL"), "/")
    parsed, err := url.Parse(base)
    if err != nil || parsed.Scheme != "https" || parsed.Host == "" || parsed.Path != "/v1" || parsed.RawQuery != "" || parsed.Fragment != "" || parsed.User != nil {
        panic("base must be an HTTPS service URL ending in /v1")
    }
    key := required("INFRAI_API_KEY")
    tenant := required("TENANT_DOMAIN")
    client := &http.Client{
        Timeout: 15 * time.Second,
        CheckRedirect: func(req *http.Request, via []*http.Request) error {
            return http.ErrUseLastResponse
        },
    }
    inventory, err := readJSON(client, base, key, "/dns/domain/list")
    if err != nil {
        panic(err)
    }
    domain := findDomain(inventory, tenant)
    if domain == "" {
        panic("tenant domain absent from returned DNS inventory")
    }
    email, err := readJSON(client, base, key, "/email/domain/get/"+url.PathEscape(domain))
    if err != nil {
        panic(err)
    }
    output, err := json.MarshalIndent(email, "", "  ")
    if err != nil {
        panic(err)
    }
    fmt.Println(string(output))
}
Enter fullscreen mode Exit fullscreen mode

That output is an inspection artifact. The program does not turn an arbitrary JSON response into a successful domain verification or a mail acceptance metric. It also does not provision records, rotate DKIM, or send a message. Those operations need their own discovered contracts and, for writes, deliberate idempotency. Keep the actual acceptance probe separate and record its observed result; successful HTTP transport from a domain lookup cannot substitute for it.

Choose the stack by the evidence it lets you retain

A fair comparison starts with the handoff your team must operate. These are alternative compositions, not measured rankings of deliverability. There is no comparative acceptance-rate benchmark here.

Composition Operational fit Boundary to account for
Cloudflare DNS with Resend A choice when the team wants those DNS and email services separately Two provider signups and two credential sets; application glue must connect domain identity, expected mail records, and later mail evidence
Amazon Route 53 with Amazon SES A choice when the team already operates its tenant workflow within AWS One AWS signup can cover both; an appropriately authorized IAM identity can access both services, but the application still connects DNS changes to email checks

Cloudflare, Route 53, SES, and Resend are real alternatives to evaluate against the same tenant acceptance criteria. Separate products let the team choose the DNS and mail components independently. They also leave the cross-service readiness decision in the application. A shared account or credential does not remove that decision.

For the two-provider composition, the glue includes mapping the mail domain to the DNS zone, recording the expected SPF/DKIM configuration, checking it after changes, and correlating the result with a controlled message. The AWS composition needs that correlation too, even if account administration is already familiar. Neither arrangement should be rejected merely because it requires integration work; existing operational knowledge can make that work the better trade.

Prefer the composition that lets an on-call retrieve the evidence behind a readiness decision. Can the team explain why harbor.support.example passed yesterday and fails now? Can it distinguish a stale check from a fresh rejection? A short integration is useful, but those answers determine whether the monitor will help during a page.

Tune the page around uncertainty and its cost

Close the trace by walking backward from the proposed page. A failed acceptance check should lead to the latest provider result, the observed resolution target, and the relevant record snapshot. If those observations disagree, retain the disagreement. Replacing every result with a single green or red flag discards the information needed to choose the next action.

The threshold has a cost.

Paging on every transient disagreement can turn ordinary provisioning waits into repeated interruptions. Waiting through too many failed outcomes can let an unusable support address become a customer ticket. Choose the confirmation policy against that trade-off, keep unknown results visible, and review which observations actually preceded tickets before tightening the threshold. A quiet pager is useful only if tenant mail readiness still has evidence behind it.

Further reading

References for authentication semantics and the alternative service contracts:

Top comments (0)