# YAML configuration reference

A single YAML document defines **one check**. All check types use the same top-level layout:

```yaml
# type is explicit and recommended; legacy files without type remain valid.
type: https              # dns | tcp | http | https
name: Public API
url: https://example.org/health
metadata:
  owner: operations
  environment: production
timeouts:
  connect: 3
  response: 5
  total: 12
monitoring:
  output: nagios
  on_failure: critical
```

## Protocol selection

| `type` | Required target | What is checked | Protocol-specific sections |
| --- | --- | --- | --- |
| `dns` | `dns:` mapping | DNS answers / optional server consistency | `dns`, `evidence.dns_rrset` |
| `tcp` | `url: tcp://host:port` | TCP connect | `connection`, `timeouts` |
| `http` | `url: http://host/path` | HTTP request / assertions | `request`, `auth`, `proxy`, `tests`, `connection`, `evidence.http_headers` |
| `https` | `url: https://host/path` | HTTP plus TLS validation | HTTP sections plus `tls`, `evidence.tls_fingerprint` |

`type` must agree with the target. `dns` and `url` are mutually exclusive. `type` is optional for compatibility with older files, but recommended for all new checks. **TLS is not a standalone check type:** use `type: https` with `tls` and TLS evidence. For a plain TLS-port reachability check use `type: tcp`; this does not validate a certificate.

## Shared sections

| Section | Keys | Meaning |
| --- | --- | --- |
| `type` | `dns`, `tcp`, `http`, `https` | Explicit protocol discriminator |
| `name` | string | Human-readable check name |
| `metadata` | `owner`, `environment`, `description`, `runbook`, `tags` | Operational ownership; tags are a list |
| `timeouts` | `connect`, `response`, `total` | Positive seconds; `total` is the logical deadline |
| `monitoring` | `output`, `on_failure`, response-time thresholds | Nagios/Icinga/Checkmk/JSON/text result selection |
| `execution` | `retries`, `retry_delay`, `success_required`, `backends` | Retry and backend orchestration |
| `tests` | `status`, `headers`, `body`, `structured`, etc. | HTTP assertions; see assertions guide |
| `evidence` | `http_headers`, `tls_fingerprint`, `dns_rrset` | Explicit, bounded diagnostic capture |

## DNS check

```yaml
type: dns
name: DNS example
dns:
  name: example.org
  records:
    A: [93.184.215.14]
  nameserver: 1.1.1.1
  port: 53
  transport: auto
  timeout: 3
  dnssec: false
  # compare_nameservers: [1.1.1.1, 8.8.8.8]
  # require_identical: true
timeouts:
  total: 12
monitoring:
  output: nagios
```

DNS record expectations are configured under `dns.records`; they are not HTTP assertions. DNSSEC record inspection is not a cryptographic chain-of-trust verification.

## TCP check

```yaml
type: tcp
name: SSH listener
url: tcp://127.0.0.1:22
timeouts:
  connect: 3
  total: 10
monitoring:
  output: nagios
```

TCP does not perform TLS negotiation, HTTP requests, or banner assertions.

## HTTP check

```yaml
type: http
name: Plain HTTP redirect
url: http://example.org/
request:
  method: GET
  follow_redirects: false
tests:
  status:
    allow: [200, 301, 302]
timeouts:
  connect: 3
  response: 5
  total: 12
monitoring:
  output: nagios
```

## HTTPS + TLS check

```yaml
type: https
name: Secure API
url: https://example.org/health
tls:
  verify: true
  # ca_file_env: IPSONIC_CA_FILE
request:
  method: GET
tests:
  status:
    allow: [200]
evidence:
  tls_fingerprint: true
  http_headers: [content-type, strict-transport-security]
timeouts:
  connect: 3
  response: 5
  total: 12
monitoring:
  output: nagios
```

For private PKI, use `tls.ca_file_env` instead of disabling verification. HTTP authentication belongs under `auth` and should reference environment variables (`token_env`, `password_env`). Never store live credentials in example YAML.

## Validating and exploring

```bash
python3 ipsonic-probe.py --validate --strict examples/198-protocol-dns-explicit.yaml
python3 ipsonic-probe.py --explain examples/201-protocol-https-explicit.yaml
python3 ipsonic-probe.py --lint examples/
python3 ipsonic-probe.py --inventory examples/ --format tsv
```

Strict mode detects unknown keys in supported sections and literal authentication secrets; it does **not** yet enforce a complete nested JSON Schema. Consult [User Guide](user-guide.html), [Assertions & Evidence](assertions-evidence.html), and the [Examples](examples/index.html) for advanced options. This reference intentionally distinguishes protocol-specific features instead of implying every setting applies to every protocol.
