# Sending Logs: Netlify and other HTTP drains

Netlify's **log drains** push your site's traffic, function and edge function logs to an HTTPS endpoint (log
drains are an Enterprise feature of Netlify). Tailcove has an endpoint for them, and a generic one for any
other platform that can push JSON or NDJSON to a URL.

## Netlify

1. In Tailcove, open (or create) the source the logs should go to and copy its **ingest token**.
2. In Netlify, open the site's configuration, **Log Drains**, and add a drain with the **general HTTP
   endpoint** destination. Choose the log types to send (traffic, function, edge function) and **JSON** or
   **NDJSON**.
3. Set the endpoint to

   ```
   https://ingest.tailcove.dev/api/v1/netlify/drain?token=YOUR_INGEST_TOKEN
   ```

   Netlify's general endpoint authenticates through the URL, so the token goes in `?token=`. (If your Netlify
   setup does offer a custom header, `Authorization: Bearer YOUR_INGEST_TOKEN` is safer and `?token=` can go.)
   A token in a URL is easier to leak than one in a header, so rotate it if the URL is ever shared.

## What arrives

One line per record. Tailcove does not depend on Netlify's field names, which differ between log types and
change: it looks for a time, a level, a message and a host under the names such platforms use, and the whole
record is kept in the line's context, with `drain` set to `netlify`, so every field Netlify sends is
searchable.

- A **function log** keeps its message and level.
- A **traffic log** has no message, so one is made from the request: `GET /cart 404`. A response of 500 or
  more is an error and 400 or more a warning.

## Any other platform

The generic endpoint takes a JSON array, one JSON object or NDJSON (gzip too), from anything that can push
to a URL:

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

with `Authorization: Bearer YOUR_INGEST_TOKEN` (or `?token=`). It recognizes the usual names for the time
(`timestamp`, `time`, `@timestamp`, `date`), level (`level`, `severity`), message (`message`, `msg`, `log`,
`text`), host (`host`, `hostname`) and, for an access log with no message, the method, path and status
(including Cloudflare Logpush's `ClientRequestMethod`, `ClientRequestURI` and `EdgeResponseStatus`). A line
that is not JSON is stored as it is. Use it for Cloudflare Logpush's HTTP destination, Fastly and any
other drain.

## Notes

- Records take the ordinary log path: they count toward your plan's included GB and share its rate limit
  (`429` when over, which platforms retry).
- A request may carry up to 5 MB and 10,000 records. An empty request, a platform's test ping, is accepted.
- Vercel has its own endpoint, [`/api/v1/vercel/drain`](https://tailcove.dev/docs/sending-logs/vercel).
