# monitorly discover

> Draft checks from what a repository already declares - compose files, Kubernetes manifests, Terraform, nginx, Caddy, cron, systemd timers and CI schedules - and the files it never opens.

`monitorly discover` reads a repository on your machine and prints a draft [`monitorly.yaml`](https://docs.monitorly.cloud/cli/monitorly-yaml.md): HTTP, SSL, domain, DNS and TCP checks for the hosts it finds, and heartbeat checks for scheduled jobs. The server never sees your files, and the draft applies nothing: you or your agent edit it, then run `monitorly plan`.

```sh title="In your repository"
monitorly discover --out monitorly.yaml
```

| Flag             | Meaning                                                                                                        |
| ---------------- | -------------------------------------------------------------------------------------------------------------- |
| `PATH`           | Directory or file to read; the current directory by default                                                    |
| `--out FILE`     | Write the draft to a file; an existing file needs `--force`                                                    |
| `--project NAME` | The project name in the draft; the directory's name by default                                                 |
| `--dns`          | Look up public host names and skip checks of names that do not resolve. The only network access of the command |
| `--json`         | `{config, candidates, skipped}` instead of YAML                                                                |

The same input always gives the same draft.

## What the draft contains

- Only fields the server accepts: `ref`, `name`, `intervalSecs`, `kind`. Fields with a server default are left out.
- No `nodes`: which nodes should check a target is your choice. A comment above `checks:` says to add `nodes:` from `monitorly node list`; the server refuses checks without them.
- Comments that explain each check and are never sent: `# from <file>:<line>: <why>`, `# needs a private node: …` for internal targets, and at the end, everything it saw and did not turn into a check, with the reason.
- Intervals to review: 60 seconds for HTTP, TCP and DNS; 1 hour for SSL and domain checks.

## What it reads

Only files whose names match a reader are opened.

| Files                                                        | What it takes                                                                                                                                            |
| ------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `docker-compose*.yml`, `compose*.yml`                        | Published TCP ports, Traefik `Host(…)` rules, caddy-docker-proxy labels, nginx-proxy `VIRTUAL_HOST`, healthcheck URLs on published ports                 |
| Kubernetes manifests and `helm template` output              | `Ingress` hosts and TLS, `HTTPRoute` and `GRPCRoute` host names, Traefik `IngressRoute`, `LoadBalancer` services, `CronJob` schedules                    |
| `*.tf`                                                       | Zones and A, AAAA, CNAME and MX records of Cloudflare, Route 53 and Google Cloud DNS, and registered domains. Only string literals; nothing is evaluated |
| `Caddyfile`, `*.caddyfile`                                   | Site addresses                                                                                                                                           |
| nginx configs (`nginx.conf`, `conf.d/`, `sites-enabled/`, …) | `server_name` and TLS `listen` ports                                                                                                                     |
| `crontab`, `*.cron`, `cron.d/`                               | Schedule and program name                                                                                                                                |
| `*.timer`                                                    | `OnCalendar=` and the other timer settings                                                                                                               |
| `.github/workflows/*.yml`                                    | `on.schedule` cron and the workflow name                                                                                                                 |
| `.gitlab-ci.yml`                                             | Scheduled jobs, listed as skipped: their schedule lives in GitLab's settings, not in the file                                                            |
| `package.json`                                               | `homepage`, unless it points to code hosting                                                                                                             |

## What it never opens

These are skipped by name, before reading: the draft lists their paths, never their contents.

- environment files: `.env`, `.env.*`, `*.env`, `.envrc`;
- keys and certificates: `*.pem`, `*.key`, `*.p12`, `*.pfx`, `*.jks`, `*.crt`, `*.gpg`, `*.age`, `id_rsa*`, `id_ed25519*` and similar;
- Terraform variables and state: `*.tfvars`, `*.tfstate*`;
- credential files: `.netrc`, `.npmrc`, `.pypirc`, `.pgpass`, `.git-credentials`, `kubeconfig*`;
- any name containing `secret`, `credential`, `password`, `passwd` or `token`;
- other `*.conf` files.

Hidden directories (except `.github/workflows`), `node_modules`, `target`, `vendor` and virtual environments are not entered; symbolic links are not followed; files over 1 MiB are not read. Environment values (except `VIRTUAL_HOST`), cron commands, Kubernetes `Secret` and `ConfigMap` documents and TXT records never appear in the output.

## How findings become checks

- Each public host gets an HTTP check (`GET /`) and, when any source says it uses TLS or none says otherwise, an SSL check.
- Each registrable domain gets one domain check.
- Terraform records with literal values get DNS checks that expect those values.
- Internal targets (loopback, private ranges, single-label names, `.local`, `.internal`, `cluster.local` and similar) are marked as needing a [private node](https://docs.monitorly.cloud/nodes/install.md) and get no domain check. Placeholders such as `example.com` are skipped.
- A scheduled job becomes a heartbeat check. With exactly one schedule, the draft keeps it as `kind.schedule`; the period is the longest gap between runs, and the grace about a tenth of it. Crontab and timer files do not name their time zone, so the schedule is read in the workspace's time zone: set `timezone` if the host's differs.
