# Website monitoring

> Regular HTTP checks of a URL: status code, redirects and optionally a text or regex in the response. On failure you get an incident and an alert.

At the interval you set, Upstat sends an HTTP request to your URL and compares the response with what you expect. A failure shows up on the monitor state right away.

## What is checked

1. The checker sends a request to the URL. Only the http and https schemes are supported.
2. It checks the response status code. 200 is expected by default.
3. If a text or a regular expression is set, it also reads the response body (up to 1 MB) and searches it.
4. It measures the response time and sends the result to Upstat, which decides the state.

## Monitor settings

The checker really reads all of this from the monitor configuration.

| Monitor settings | Where to set it |
|---|---|
| **Address** (`url`): The full URL including http:// or https://. An address that is directly an IP in a private or loopback range is rejected. | Dashboard and REST API |
| **Method** (`method`): GET by default. For a lighter check that does not download the body you can pick HEAD. POST, PUT, PATCH and DELETE are supported too. | Dashboard and REST API |
| **Custom headers** (`headers`): Name and value pairs, for example Authorization. The Host and Transfer-Encoding headers are ignored. | Dashboard and REST API |
| **Follow redirects** (`follow_redirects`): On by default, up to 5 redirects are followed. When off, a redirect counts as the response with its own status code. | Dashboard and REST API |
| **Expected status code** (`expected_status`): The number the server has to return. 200 by default. Any other code is a failure. | Dashboard and REST API |
| **Text to find** (`contains`): A text or regular expression that must be in the response body. If it is not a valid regex, it is searched as plain text. | Dashboard and REST API |
| **Timeout** (`timeout_ms`): The longest time in milliseconds the checker waits for a response. Without a value the checker default applies. | Dashboard and REST API |

## Example through the REST API

Creates a monitor that expects status 200 every 5 minutes and the word "OK" in the response. The request is authenticated with an API token.

Creating a website monitor with curl

```
curl -X POST https://upstat.sk/api/v1/monitors \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Main site",
    "type": "website",
    "interval_seconds": 300,
    "config": {
      "url": "https://example.com/",
      "method": "GET",
      "expected_status": 200,
      "contains": "OK",
      "follow_redirects": true
    }
  }'
```

## What counts as a failure

- The status code differs from the expected one.
- The response body does not match the text or regex.
- The server does not answer within the timeout or cannot be reached (DNS, TCP, TLS).
- There are more than 5 redirects.

## What happens on failure

- The monitor changes from UP to DOWN. If you use ignore blips, the failure first has to last for the time or the number of checks you set.
- An incident named after the monitor is created automatically. When a check passes again, the incident closes itself.
- Your alert rules send a message through the channels you set up: Slack, Discord, Telegram, email, SMS, push, webhook or ntfy.
- If the monitor is linked to a status page component, its state shows up there too.

## How it works with ignore blips

A short outage does not have to mean DOWN right away. For each monitor you can set state stabilization. Upstat decides it when it processes check results, not the checker.

- `consecutive_failures`: How many checks in a row must fail before the monitor is marked DOWN. For example 3 means three failures in a row.
- `min_down_seconds`: How long the failing has to last before the state changes to DOWN.
- `min_up_seconds`: How long everything has to be fine after an outage before the monitor goes back to UP. It protects against rapid flapping.

For a website, ignoring blips helps most when the server does not answer for a few seconds during a deploy or restart. Two or three failures in a row usually separate a real outage from a restart.

[How monitoring works](https://upstat.sk/en/how-monitoring-works)

## Limits by plan

The shortest allowed interval between checks depends on the plan. The numbers are read straight from the plan settings.

| Plan | Shortest check interval |
|---|---|
| Hobby | 120 s |
| Starter | 60 s |
| Pro | 30 s |

## Questions about this type

### Can a page behind a login be checked?

Yes, if sending a custom header such as Authorization with a token is enough. The checker does not fill in a login form with cookies.

### Is the SSL certificate checked too?

A website monitor verifies the certificate only as part of the connection: it fails on an invalid certificate. Days until expiry are watched by a separate SSL monitor.

## Other monitor types

- [SSL certificate](https://upstat.sk/en/monitors/ssl)
- [TCP port](https://upstat.sk/en/monitors/port)
- [Heartbeat](https://upstat.sk/en/monitors/heartbeat)
- [API endpoint](https://upstat.sk/en/monitors/api)
- [Docker container](https://upstat.sk/en/monitors/docker)
- [Database](https://upstat.sk/en/monitors/database)
- [How monitoring works](https://upstat.sk/en/how-monitoring-works): The check cycle, outage confirmation and monitor states.
- [Alerting](https://upstat.sk/en/alerting): Rules, thresholds and alert channels.
