# Log drains to your own bucket: Cloudflare, Fastly and more

Choose a log drain endpoint by payload format. Vercel, Heroku and Convex each use a dedicated endpoint. Platforms that send plain JSON use `/v1/events/json`, and Supabase sends OpenTelemetry to the OTLP logs endpoint. Your stream determines where the records are stored.

## How it works

```text
Vercel                       ──JSON or NDJSON─────▶ /v1/events/vercel ─┐
Heroku                       ──logplex syslog─────▶ /v1/events/heroku ─┤
Netlify, Auth0, Akamai,      ──JSON or NDJSON─────▶ /v1/events/json   ─┼─▶ your stream's destination
  Cloudflare Logpush, Fastly                                           │
Convex                       ──JSON array─────────▶ /v1/events/convex ─┤
Supabase                     ──OTLP/HTTP protobuf─▶ /v1/logs          ─┘
```

- Each log record becomes one line with `signal` `log`. JSON records are kept as sent, Heroku syslog messages are parsed into fields, and Supabase records are OpenTelemetry log records with their resource and scope. [Delivery format](../delivery-format.md#log-drains) lists them.
- A `200` means the records are stored durably and will be delivered at least once. See [Delivery semantics](../delivery-semantics.md).
- The platform's own retries are not deduplicated: a request retried after a lost response is stored again.

## 1. Create a stream and a key

Create an ingestion stream in the [dashboard](pathname:///app/), add a destination, and copy the stream's API key and ID. A key for one stream needs no stream ID in the drain. One stream per platform keeps the record shapes apart in your queries.

## 2. Add the drain

### Vercel

Endpoint `https://api.send2bucket.com/v1/events/vercel`, with the key in an `Authorization` custom header. [Vercel log drains](./vercel-log-drains.md) has the setup and queries for Vercel's fields.

### Heroku

`heroku drains:add` with the key as the Basic auth password in the drain URL. [Heroku log drains](./heroku-log-drains.md) has the setup and queries for Heroku's app and router lines.

### Supabase

Supabase's OpenTelemetry (OTLP) log drain goes to `https://api.send2bucket.com/v1/logs` with the key in an `Authorization` header. [Supabase log drains](./supabase-log-drains.md) has the setup and queries.

### Netlify

A **General HTTP endpoint** drain goes to `https://api.send2bucket.com/v1/events/json?stream=<stream_id>` with `Bearer <key>` as the authorization header. [Netlify log drains](./netlify-log-drains.md) has the setup and queries for traffic and function logs.

### Auth0

[Auth0 log streams](https://auth0.com/docs/customize/log-streams/custom-log-streams) are on paid plans. Create a stream of type **Custom Webhook**:

- Payload URL: `https://api.send2bucket.com/v1/events/json?stream=<stream_id>`
- Authorization Token: `Bearer <key>`. Auth0 sends the field as the whole `Authorization` header.
- Content Format: JSON Lines, JSON Array or JSON Object; all three work.

### Akamai DataStream 2

Add a [custom HTTPS destination](https://techdocs.akamai.com/datastream2/docs/stream-custom-https) to the stream, with the JSON log format:

- Endpoint URL: `https://api.send2bucket.com/v1/events/json?stream=<stream_id>`
- Authentication: **Basic**, any username, the API key as the password. Akamai does not let a custom header set `Authorization`.

Akamai checks the destination by posting `{"access_validation":true}`; Send2Bucket answers it and stores nothing.

### Cloudflare Logpush

[Logpush to an HTTP destination](https://developers.cloudflare.com/logs/logpush/logpush-job/enable-destinations/http/) is set up through the API. Headers go in the destination URL as `header_` parameters:

```bash
curl https://api.cloudflare.com/client/v4/zones/<zone_id>/logpush/jobs \
  -H "Authorization: Bearer <cloudflare_api_token>" \
  -H "Content-Type: application/json" \
  --data '{
    "name": "send2bucket",
    "dataset": "http_requests",
    "destination_conf": "https://api.send2bucket.com/v1/events/json?header_Authorization=Bearer%20<key>&header_S2b-Stream=<stream_id>",
    "max_upload_bytes": 5000000
  }'
```

Logpush gzips its uploads; Send2Bucket decompresses them, with or without a `Content-Encoding` header, and drops the `{"content":"tests"}` upload Cloudflare sends to check the destination. 5 MB is the smallest `max_upload_bytes`; Cloudflare does not say whether it counts it before or after compression, so watch for `413` errors on busy zones. [Workers Logpush](https://developers.cloudflare.com/workers/observability/logs/logpush/) works the same way with the `workers_trace_events` dataset.

### Fastly

Add an [HTTPS logging endpoint](https://www.fastly.com/documentation/guides/integrations/logging-endpoints/log-streaming-https/) to the service:

- URL: `https://api.send2bucket.com/v1/events/json?stream=<stream_id>`
- Custom header name `Authorization`, value `Bearer <key>`
- JSON log entry format: **Array of JSON** or **Newline delimited**, with a JSON log line format such as `{"host":"%{req.http.host}V","url":"%{json.escape(req.url)}V","status":%{resp.status}V}`
- Maximum bytes: under 8 MiB

Fastly checks that the host accepts its logs at `/.well-known/fastly/logging/challenge` before streaming; Send2Bucket answers for every service.

### Convex

[Convex log streams](https://docs.convex.dev/production/integrations/log-streams/) are on the Pro plan. Add a **Webhook** log stream; Convex takes only a URL, so the key goes in it:

```text
https://api.send2bucket.com/v1/events/convex?api-key=<key>&stream=<stream_id>
```

Convex sends a `verification` event when you save the stream; Send2Bucket answers it and stores nothing. The `x-webhook-signature` header is not checked.

For AWS and Google Cloud logs, see [CloudWatch Logs through Firehose](./aws-cloudwatch-logs.md) and [Cloud Logging through Pub/Sub](./gcp-cloud-logging.md).

## 3. Check the endpoint

Before the platform sends anything, check the key and stream with one request. It stores one record, and the answer is a `200` with an empty body:

```bash
curl -i https://api.send2bucket.com/v1/events/vercel \
  -H "Authorization: Bearer $S2B_API_KEY" \
  -H "S2b-Stream: <stream_id>" \
  --data-binary '{"id":"check","level":"info","message":"hello from curl"}'
```

A `401` means the key is wrong or revoked; a `403` or `400` names the stream problem; a `409` means the stream has no destination. The [API reference](../api-reference.md#log-drains) lists every error.

## 4. Query the logs

[DuckDB](../querying/duckdb.md) reads the objects in place. This view keeps the drained logs; the `stream` column comes from the object path:

```sql
INSTALL httpfs; LOAD httpfs;
CREATE SECRET s2b (TYPE s3, PROVIDER credential_chain, REGION '<region>');

CREATE VIEW drains AS
SELECT * FROM read_json(
  's3://<bucket>/<prefix>/s2b/stream=*/date=*/hour=*/*.ndjson.gz',
  format = 'newline_delimited',
  hive_partitioning = true,
  columns = {v: 'INTEGER', delivery_batch_id: 'VARCHAR', batch_id: 'VARCHAR',
             received_at: 'TIMESTAMPTZ', signal: 'VARCHAR',
             resource: 'JSON', scope: 'JSON', data: 'JSON'})
WHERE signal = 'log';
```

Records per stream and day, with one stream per platform:

```sql
SELECT stream, date, count(*) AS records
FROM drains
GROUP BY ALL
ORDER BY date DESC, records DESC;
```

The [Vercel](./vercel-log-drains.md), [Heroku](./heroku-log-drains.md), [Supabase](./supabase-log-drains.md) and [Netlify](./netlify-log-drains.md) guides have queries for each platform's fields.

In an Iceberg or DuckLake table, the same line is in the `payload` column with `signal_type` `log`; see [Table columns](../delivery-format.md#table-columns).

## Notes

- **Size**: records have no size limit of their own. A request can be up to 8 MiB decompressed; Vercel sends up to 1 MB per request. Set a smaller batch size where the platform has one.
- **Billing**: each record's JSON as stored is the number billed, so a Heroku line costs its parsed JSON, not its syslog text.
- **Retries**: see [Retries](../api-reference.md#retries). To drop repeats, key on the record's own ID, such as Vercel's `id`, in your query.
- **Keys in URLs**: a key in the URL can end up in the platform's logs. Use a header where the platform offers one, and a key for one stream. See [Drain keys and streams](../api-reference.md#drain-keys).
