> ## Documentation Index
> Fetch the complete documentation index at: https://docs.devhelm.io/llms.txt
> Use this file to discover all available pages before exploring further.

# DNS Monitor Configuration

> Configure DevHelm DNS monitors — hostname, record types, nameservers, and DNS assertions

DNS monitors require a hostname and support assertions against resolution results, response times, and specific record values.

<Tip>
  **Define this in code.** [YAML format](/mac/yaml/monitors) · [Terraform](/mac/terraform/monitors)
</Tip>

## Config fields

| Field                   | Type            | Required | Default                  | Description                                                                                |
| ----------------------- | --------------- | -------- | ------------------------ | ------------------------------------------------------------------------------------------ |
| `config.hostname`       | string          | Yes      | —                        | Domain name to resolve                                                                     |
| `config.recordTypes`    | array of string | No       | `["A", "AAAA"]`          | Record types to query: `A`, `AAAA`, `CNAME`, `MX`, `NS`, `TXT`, `SRV`, `SOA`, `CAA`, `PTR` |
| `config.nameservers`    | array of string | No       | `["8.8.8.8", "1.1.1.1"]` | Custom nameservers to query, tried in order                                                |
| `config.timeoutMs`      | integer         | No       | `1500`                   | Per-resolver timeout in milliseconds                                                       |
| `config.totalTimeoutMs` | integer         | No       | `4000`                   | Total timeout for all queries in milliseconds                                              |

## Assertions

| Assertion                | Required fields           | Description                                        |
| ------------------------ | ------------------------- | -------------------------------------------------- |
| `dns_resolves`           | *(none)*                  | Passes if the hostname resolves at all             |
| `dns_response_time`      | `maxMs`                   | Fails if resolution takes longer than threshold    |
| `dns_response_time_warn` | `warnMs`                  | Records degraded hint for elevated resolution time |
| `dns_expected_ips`       | `ips` (array)             | Fails if resolved IPs don't match expected set     |
| `dns_expected_cname`     | `value`                   | Fails if CNAME target doesn't match                |
| `dns_record_contains`    | `recordType`, `substring` | Fails if record value doesn't contain substring    |
| `dns_record_equals`      | `recordType`, `value`     | Fails if record value doesn't match exactly        |
| `dns_txt_contains`       | `substring`               | Fails if no TXT record contains substring          |
| `dns_min_answers`        | `recordType`, `min`       | Fails if answer count is below minimum             |
| `dns_max_answers`        | `recordType`, `max`       | Fails if answer count exceeds maximum              |
| `dns_ttl_low`            | `minTtl`                  | Fails if TTL is below minimum                      |
| `dns_ttl_high`           | `maxTtl`                  | Fails if TTL exceeds maximum                       |

## Examples

### Basic resolution check

```yaml theme={null}
monitors:
  - name: Domain resolves
    type: DNS
    config:
      hostname: example.com
    assertions:
      - config:
          type: dns_resolves
        severity: fail
```

### Full validation with expected IPs

```yaml theme={null}
monitors:
  - name: Production DNS
    type: DNS
    config:
      hostname: api.example.com
      recordTypes: [A, AAAA]
      nameservers: ["8.8.8.8", "1.1.1.1"]
    frequencySeconds: 300
    regions: [us-east, eu-west]
    assertions:
      - config:
          type: dns_resolves
        severity: fail
      - config:
          type: dns_expected_ips
          ips: ["203.0.113.10", "203.0.113.11"]
        severity: fail
      - config:
          type: dns_response_time
          maxMs: 500
        severity: fail
      - config:
          type: dns_ttl_low
          minTtl: 60
        severity: warn
```

### SPF record validation

```yaml theme={null}
monitors:
  - name: SPF record
    type: DNS
    config:
      hostname: example.com
      recordTypes: [TXT]
    assertions:
      - config:
          type: dns_txt_contains
          substring: "v=spf1"
        severity: fail
```

## Next steps

<CardGroup cols={2}>
  <Card title="DNS overview" icon="server" href="/monitoring/dns/overview">
    When to use DNS monitors.
  </Card>

  <Card title="Regions" icon="earth-americas" href="/monitoring/regions">
    Available probe regions.
  </Card>
</CardGroup>
