# Sending Logs: Vercel

Vercel can push your project's logs to any HTTPS endpoint with a **drain**. Point one at Tailcove and your
build logs, function logs, edge and static request logs, external logs and firewall events land in a source,
searchable next to the rest of your stack.

## Set it up

1. In Tailcove, open (or create) the source the logs should go to and copy its **ingest token**.
2. In Vercel, open your team's settings, **Drains**, and add a drain. Choose **Logs**, the projects and
   environments to send, and the log sources you want (`build`, `static`, `lambda`, `edge`, `external`,
   `firewall`, `redirect`).
3. Choose **JSON** or **NDJSON** as the delivery format (both work). Protobuf is not supported.
4. Set the endpoint to

   ```
   https://ingest.tailcove.dev/api/v1/vercel/drain
   ```

   and add the token as a custom header: `Authorization: Bearer YOUR_INGEST_TOKEN`.

   If your Vercel setup cannot add a header, put the token in the URL instead:
   `https://ingest.tailcove.dev/api/v1/vercel/drain?token=YOUR_INGEST_TOKEN`. A token in a URL is easier to
   leak (a screenshot, a proxy log) than one in a header, so use the header when you can.
5. **Required:** copy the **Signature Verification Secret** Vercel shows on the drain form into the source's
   settings, under **Settings, Vercel drain signature** (see Notes). Until it is saved, Tailcove refuses every
   request from Vercel's drain with a `403` (`drain_secret_required`). Do this before you send the test.
6. Send a test. Tailcove answers `202` with the number of records it took; a test with nothing in it is
   accepted too.

## What arrives

One line per Vercel log record. The message is Vercel's own. A request log has no message, so Tailcove
makes one from the request, such as `GET /api/users 200`. The level is the one Vercel gave, except that a
response of 500 or more is an error and 400 or more a warning when Vercel called it info.

Everything else is kept in the line's context under Vercel's own names, so you can search by them:
`source`, `projectName`, `projectId`, `deploymentId`, `buildId`, `requestId`, `statusCode`, `path`,
`environment`, `executionRegion`, `entrypoint`, `traceId`, `spanId` and the whole `proxy` object (method,
host, path, client IP, user agent, region, cache status). The host of the line is the deployment's host, and
`drain` is `vercel`.

## Traces

Vercel can also push **traces** (OpenTelemetry). Point a trace drain at

```
https://ingest.tailcove.dev/api/v1/otlp/v1/traces
```

with the same `Authorization: Bearer` header, and they appear in your Traces tab, joined to the logs by
`traceId` and `spanId`. See [OpenTelemetry traces](https://tailcove.dev/docs/opentelemetry/traces).

## Notes

- The drain's records take the ordinary log path: they count toward your plan's included GB and are
  subject to the same rate limit as any other line. A request over the limit gets a `429`, which Vercel
  retries.
- A request may carry up to 5 MB and 10,000 records.
- A Vercel drain needs two things: the ingest token and the drain's **secret** (Vercel shows it on the drain
  form), saved under **Settings, Vercel drain signature** on the source. Tailcove refuses a Vercel request
  unless its `x-vercel-signature` header matches that secret (a `403`), so a leaked ingest token alone cannot
  forge logs. The secret is stored encrypted and never shown again;
  to rotate it, save the new one at the same time you change it in Vercel.
- A drain can be paused or deleted in Vercel at any time; Tailcove keeps what it already received for the
  source's retention.
