# Monitors

Monitors tell you when something you run stops working. There are seven kinds:

- **HTTP** checks a URL on a schedule.
- **TCP** checks that a host accepts connections on a port.
- **Ping** checks that a host answers ICMP echo requests.
- **Heartbeat** waits for your own cron job or worker to check in, and alerts you when it goes quiet.
- **DNS** looks up a record and checks it against the value you expect.
- **SSL certificate** warns you before a certificate expires.
- **Domain** warns you before a domain registration expires.

Heartbeats have their own tab on the Monitors page (**Heartbeats**), with when each job last pinged, when the next
ping is due and how long its last run took; **New heartbeat** opens the form on a heartbeat.

**Test now.** On the form, **Test now** runs the check once from Tailcove with what you typed, before you save, and says
what a real check would have seen (status, time, or the error).

**Smart setup.** When you add an `https://` website, the form offers to also watch its **SSL certificate** (ticked) and
its **domain's registration**, made in the same save and told the same way. Each counts toward your plan's monitors.

All of them share the same notification channels as [alerts](https://tailcove.dev/docs/alerts#notification-channels)
(email, Slack, Discord, webhook, GitHub issue, Teams, Telegram, PagerDuty and
Opsgenie), incident history, uptime figures and status pages. A team's plan
sets how many monitors it can have.

## HTTP monitors

Tailcove requests the URL every 30 seconds, every minute or every five minutes (the
two shorter intervals need a paid plan) and expects a status code, by default `200`. You can
also ask for a keyword that must appear in the response body.

**Custom requests.** Choose the method (GET, HEAD, POST, PUT, PATCH, DELETE or OPTIONS), add up to ten
request headers and, for POST, PUT, PATCH and DELETE, a body of up to 4,096 characters. Headers that
describe the connection or the message (`Host`, `Content-Length`, `Transfer-Encoding`, `Connection` and
the like) cannot be set. Header values are stored encrypted and are not shown again; leave a value empty
when you edit to keep the one saved. Headers and body go **only to the host in the URL**: on a redirect to
another host, port or scheme the request is sent without them, so a credential cannot reach a third party.

**Where the time goes.** The monitor's page breaks the average response time into DNS lookup, connect,
TLS handshake and first byte. A phase that does not happen (no TLS on `http://`) shows 0.

A monitor goes **down after two failed checks in a row**, so one dropped
request does not page anyone. It comes back **up on the first successful
check**.

**Slow-response alerts** (HTTP, TCP and ping). Set **Slower than** a number of milliseconds, **Or slower than its
usual** (1.5, 2, 3 or 5 times its average over the last 7 days, once it has at least 50 checks), or both. After three
slow checks in a row you are told it is slow (the list shows **Slow**), and after three normal ones that it is back to
normal. Slowness goes to email, Slack, Discord, webhooks, Teams and Telegram, never opens an incident, a GitHub issue
or a page through PagerDuty or Opsgenie, and sends at most four notices an hour.

## TCP monitors

A TCP monitor opens a connection to a host and port, for example
`db.example.com` and `5432`, and closes it again. It sends and reads nothing, so
it only tells you whether something is listening. It follows the same
30-second, one-minute or five-minute schedule and the same two-strikes rule as an
HTTP monitor.

The host has to be a public hostname or IP address. Private, loopback and
link-local addresses, and names that resolve to them, are refused when you save
the monitor and again on every check.

## Ping monitors

A ping monitor sends up to three ICMP echo requests to a host and is up as soon
as one is answered; the response time is that round trip. It follows the same
30-second, one-minute or five-minute schedule and two-strikes rule as the others,
and the host has to be public in the same way. Many hosts and firewalls drop
ping on purpose: if yours does, use a TCP check on an open port instead.

## Heartbeat monitors

A heartbeat reverses the direction: your job calls Tailcove. When you save the
monitor you get a **ping URL** like

```
https://ingest.tailcove.dev/api/v1/heartbeat/<token>
```

Request it each time the job finishes. At the end of a crontab line:

```
0 3 * * * /usr/local/bin/backup.sh && curl -fsS -m 10 --retry 3 https://ingest.tailcove.dev/api/v1/heartbeat/<token>
```

The URL accepts `GET`, `POST` and `HEAD`, ignores any body, and answers
`200 OK`. Add a word to say how a run went:

| URL                          | Meaning                                                                      |
| ---------------------------- | ---------------------------------------------------------------------------- |
| `…/heartbeat/<token>`        | The run finished well.                                                       |
| `…/heartbeat/<token>/start`  | A run began.                                                                 |
| `…/heartbeat/<token>/fail`   | The run failed. The monitor goes down at its next check, within a minute.    |
| `…/heartbeat/<token>/<code>` | The run ended with that exit code: `0` is a success, `1` to `255` a failure. |

A cron line that tells Tailcove when it starts and how it ended:

```
0 3 * * * curl -fsS -m 10 https://ingest.tailcove.dev/api/v1/heartbeat/<token>/start; /usr/local/bin/backup.sh; curl -fsS -m 10 https://ingest.tailcove.dev/api/v1/heartbeat/<token>/$?
```

A failure stays a failure until the next success ping, which clears it and brings
the monitor back up. `/start` is optional. Anyone who has the URL can ping the monitor, so treat it like a
password. If it leaks, delete the monitor and create a new one: the old URL
stops working at once.

You set how the job is scheduled:

- **Every so often**, with **Expected every**: how often your job should run, from a minute to a week.
- **On a cron schedule**: five cron fields (`0 2 * * *`) read in a **time zone**, summer time included. The job is
  expected at each time the schedule names, so a nightly backup that should run at 02:00 is late at 02:00 plus the
  grace, however long ago it last ran. A ping up to a minute before the run counts for it. A new heartbeat waits for
  its first scheduled run. The schedule must run at least once a month.
- **Then wait another** (grace): extra time before Tailcove calls it down, so a
  slow run is not an outage.
- **A run may take at most** (optional): if your job calls `/start`, a run that
  started and has not finished within this time marks the monitor down, so a job
  that hangs is caught even though it never fails. Leave it off and runs are not
  timed.

If no ping arrives within the expected interval plus the grace, the monitor goes
**down**, and Tailcove checks once a minute. The next ping brings it back up. A
new heartbeat stays **pending** until its first ping, so a job that has not run
yet is not reported as an outage. A job that **never** reports is not pending
forever: if no first ping arrives within the expected interval plus the grace
after you set the monitor up (or saved it again), it goes down with "No ping
yet". The heartbeat period is how often your job
runs, so it has no plan minimum.

The heartbeat's page shows its schedule, its last ping, when the next is due, and its **recent runs** (the last 50
signals: each success or failure, with how long the run took when it sent `/start` first). **Connect your job** has
ready-to-copy snippets for crontab, a shell script, GitHub Actions, a Kubernetes CronJob, the Laravel scheduler and
PowerShell.

Pings are counted per monitor: a ping within five seconds of the last one is
acknowledged but not recorded again. A client that keeps requesting URLs that
do not exist is refused for a minute (`429`).

## Regions

An HTTP or TCP monitor can be checked from more than one region. On the monitor's form, under **Check from**, choose the
regions (up to 1 on Free, 2 on Pro and 3 on Business; our home region counts as one). Each region runs its own checks and
keeps its own count of failures, and the monitor is **down only when enough regions agree**: by default two, and you can
ask for one. A network problem on a single route then stays quiet.

- With no region chosen the monitor is checked from our home region alone, as before.
- A region that has gone quiet (its probe stopped reporting) has no vote. It cannot make a monitor go down, and it cannot
  hold one up; if too few regions are reporting to reach the number you chose, the monitor stays as it is.
- The monitor's page shows what each region last saw, and which ones are silent.
- Only HTTP and TCP checks run from regions. Ping, DNS, certificate, domain and heartbeat monitors are not multi-region.
- Uptime figures count the checks of every region, so a monitor that one region could not reach shows less than 100% even though
  it was never marked down.

## DNS monitors

Looks up one record of a name (A, AAAA, CNAME, TXT, MX or NS) and is up while one of the answers equals the
value you expect. Host names are compared without case or a trailing dot, an MX as `priority host`
(`10 mail.example.com`), a TXT string exactly. Internal names and addresses are refused. A failed check says
the record is missing or different, never what was answered. Down after two failed checks, like HTTP.

## SSL certificate monitors

Connects to a host and port (443 by default), reads the certificate it serves, and fails when the certificate
is expired, not trusted for the host, or expires within the number of days you choose. It is checked hourly or
daily. Because it is checked so rarely it goes down on the **first** failed check, and recovers when the
certificate is renewed.

## Domain monitors

Reads a domain's registration expiry over RDAP and fails when it is within the number of days you choose. Not
every registry publishes an expiry date over RDAP; when it does not, the monitor fails with "Registration expiry
not available", so check one works before relying on it. Checked hourly or daily; down on the first failed check.

## Maintenance windows

**Monitors, Maintenance** schedules a window (up to 14 days) for all your monitors or the ones you choose. While
it runs the checks still run and are recorded, but no incident is opened, nobody is notified, and a monitor that
was down stays as it was; when the window ends it picks up from there. Your note, with the times and the names of
the services covered, appears on the public [status page](https://tailcove.dev/docs/status-pages) of those monitors before and during
the window. A team can have 20 windows scheduled or running at once.

## Incidents and status pages

Each time a monitor goes down Tailcove opens an incident with the cause (the
status code, the connection error, or how long a heartbeat has been quiet) and
closes it when the monitor recovers. Monitors of every kind can be added to a
status page and show up in uptime figures for the last
24 hours, 7 days and 30 days. See [Status Pages](https://tailcove.dev/docs/status-pages) for the
public page, email subscriptions and using your own domain.
