# HTTP traffic

> A site's HTTP tab from the edge's access logs, no APM needed: routes, clients, countries, slow endpoints, scanners, bandwidth and request IDs.

Source: https://falak.sh/docs/observability/http-traffic/

Since v0.17.0 every site has an **HTTP** tab built from what the edge (Caddy) already logs for it, so it works for any app, with or without the [APM package](/docs/observability/apm-laravel/). It needs the [observability stack](/docs/observability/overview/#enable-the-stack).

## What you see

**Charts** (1h, 6h, 24h, 7d; per server or all): requests per second by status class, bytes in and out, p95 latency, HTTP versions (1.0, 1.1, 2, 3) and TLS versions.

**Tables**, each loaded when you open it:

| Table | Content |
|---|---|
| Paths | The top routes. Ids, UUIDs, hashes and long tokens in a path become `:id` (`/orders/:id`), so routes stay countable; the query string is never part of a route. |
| Slowest | Routes by p95 latency (routes with fewer than 5 requests left out) |
| Clients | Top client IPs with their 4xx / 5xx counts and bytes |
| User agents | Top user agents |
| Countries | Clients' countries and networks (ASN) |
| Threats | Scanners and probes (below) |

The server page has an **Edge traffic** card: the same charts summed over the sites it serves, and requests per site. Viewing needs `telemetry.view`; changing a site's thresholds needs `sites.manage`.

Charts come from counters the agent aggregates every minute; tables query the access logs (kept 15 days) over the selected range. Request bodies, cookies and headers other than the user agent and the request id are never logged.

## Slow endpoints

Every 5 minutes, over the last hour, a route is **slow** when it had at least 20 requests and a p95 of 1,000 ms or more. It becomes a **performance** Issue (*Slow endpoint: /orders/:id*) and raises an alert. It resolves only once the route is fast again under real traffic (p95 under 80 % of the threshold with enough requests); a quiet hour keeps the Issue as it is.

Per site you can change the threshold (100–60,000 ms) and the minimum requests (1–10,000). The installation default is `FALAK_HTTP_SLOW_MS`.

## Threats

Requests that match a probe or attack pattern are counted per client:

| Category | Examples |
|---|---|
| Probe | `/.env`, `/.git/`, `/wp-admin`, `/phpmyadmin`, `/vendor/phpunit`, `/cgi-bin/`, `/.aws/`, `*.sql`, `/backup.zip` |
| Traversal | `../` and its encodings, `/etc/passwd` |
| Injection | SQL injection and XSS markers in the query string |
| Method | `TRACE`, `CONNECT`, `PROPFIND`, `DEBUG` and other unusual methods |

Probes, traversal and unusual methods count **only when your site refused them** (a 4xx), so a WordPress site's own `/wp-admin` is not an attack. Injection markers count whatever the status. One IP with 50 or more 404s in the range shows as a 404 storm.

A site and rule with at least 20 hits in a 5-minute window becomes a **security** Issue (*Scanner probing /.env files*), with the latest window's top 5 client IPs as its sample. Background noise opens nothing. Each client row has a **Block** action: see [Network protection](/docs/servers/network-protection/).

## Countries and networks

Countries and ASNs come from **DB-IP Lite** (IP to Country Lite and IP to ASN Lite, [CC BY 4.0](https://db-ip.com)), downloaded by the control plane once a month. Lookups run in the control plane on the top client IPs of the range, and the card says how much of the traffic the breakdown covers. Air-gapped installs can turn the download off with `FALAK_GEOIP_ENABLED=false`; tables then show IPs without countries.

## Bandwidth

The tab shows this month's and last month's bandwidth per site (response bodies only, headers and TLS overhead not counted), kept for 400 days. Set a monthly threshold on the site to get one `http.bandwidth` alert per month once it is reached.

## Request IDs

**Off by default.** Turn on **Settings → Observability → Request IDs** (`telemetry.manage`) to have the edge stamp an `X-Request-Id` on every request:

- A request that already carries one well-formed id keeps it; otherwise the edge sets a UUID.
- The header reaches your app, and the response gets it only when the app didn't set its own.
- In the HTTP tab, search by request id: you get the access line, the app's log lines that contain the id (±15 minutes) and a link to the trace when there is one.

For the app's logs to carry the id, put it in the log context. In Laravel, a middleware registered first in the `web` and `api` groups:

```php title="app/Http/Middleware/RequestId.php"
public function handle(Request $request, Closure $next)
{
    if ($id = $request->header('X-Request-Id')) {
        \Illuminate\Support\Facades\Log::shareContext(['request_id' => $id]);
    }
    return $next($request);
}
```

With Request IDs off, every server's edge config is exactly what it was before v0.17.0. Turning it on or off reloads the edges gracefully; nothing restarts.

## Alerts

| Type | When |
|---|---|
| `http.errors_spike` | In a 5-minute window, at least 20 5xx responses and at least 10 % of the site's requests, held two windows |
| `http.slow_endpoint` | A route was found slow (cleared with its Issue) |
| `http.bandwidth` | The month's bytes out reached the site's threshold (once a month) |
| `http.scanner_surge` | 300 or more threat hits on a site in 5 minutes |

The agent-side counters need v0.17.0. With older agents, requests, 5xx and p95 fall back to queries over the access logs; protocol, TLS and threat charts stay empty until the agent is updated. Request IDs need agent feature `edge.request_id`.

## Next steps
