# HTTP

The HTTP page shows every outgoing HTTP call this server makes: from the `http` component, `BoxHttpClient`, and modules that use them such as bx-ai. It counts calls made inside a request and calls made by tasks and threads, and tells them apart.

It sits in the **Inspect** group next to Queries, because it is the same kind of question: what does my code ask other systems for, and how well does it go.

## Tabs

| Tab | What it shows |
|---|---|
| Overview | Calls, error rate, time (p95, median, p99), data received, and where the calls came from. A table by host with a status mix bar. With several servers selected, a table by server. |
| Needs attention | A host with many errors or timeouts, a slow host, an endpoint that answers 5xx, a very large response, and a request that made the same call many times (a loop of calls, like an N+1 over HTTP). The slowest endpoints, and large responses. |
| Endpoints | Every endpoint as `METHOD host path`, with the same numbers. |
| Calls | BoxLang+. The recent calls, newest first, with the request that made each one (an open link), a filter for the source, failures, slow calls and text. |

![The HTTP page](../assets/screenshots/console-http.png)

The range buttons (1h, 24h, 7d, 15d) set the period. The last hour is always available. Longer ranges read the saved rollups and need BoxLang+.

## What counts as a problem

The limits are in `collectors.http` (see [Configuration](../configuration.md#collectors)): `slowMs` (2000), `errorPct` (5), `minCalls` (20), `repeat` (20) and `largeMB` (5). A host or endpoint with fewer than `minCalls` calls is not judged, so one failed call to a quiet host is not an alarm.

* A host is **critical** when errors reach four times `errorPct`, **warning** from `errorPct`. Errors are 5xx answers and calls that got no answer. A 4xx answer is shown in the status mix and is not an error.
* A host whose p95 is above `slowMs` is slow, and critical at three times that.
* An endpoint with 5xx answers on `errorPct` percent of its calls is critical.
* A request that makes the same endpoint `repeat` times is flagged on this server (it needs the request, so it is not known for other servers).

## What is stored

A call is counted by host and by endpoint, with its status, time and size. The path is a pattern: numbers, UUIDs, long hex strings, long tokens and e-mail addresses become `:id`, so `/users/42/orders/9` is one endpoint. **The query string, headers and bodies are never kept**, and a URL's user info is dropped.

Time is the total time of the call. Core does not announce retries, redirects or the connect phase. Size is the number of characters of the answer, so it is approximate for binary data.

## Collection level

| Level | What is kept |
|---|---|
| `light` (default) | Totals by host and endpoint, in memory. With BoxLang+ they are also saved as rollups. |
| `full` | Also the list of the last 500 calls, with the template and line that made each call, and (BoxLang+) the stream of calls in the store folder. |

## Free and BoxLang+

Free keeps the last hour of this server in memory. BoxLang+ adds the longer ranges, the list of calls and the [server selector](servers.md). See [Licensing](../licensing.md).

## API

`GET /~bxlens/index.bxm/api/http?range=1h|24h|7d|15d&server=this|<id>|all` returns the numbers of the page. `GET .../api/http/calls?server=&source=request|background&failed=true&slowMs=&q=&limit=` returns the list of calls. Both are open to the viewer role. An unknown server answers 404.
