Send Vercel log drains to S3 or your own bucket
Vercel keeps runtime logs for a limited time that depends on the plan. A drain sends every log line to Send2Bucket as it is written, and Send2Bucket delivers the lines to a bucket or table you own, for as long as you keep them.
We sent requests shaped like the documented Vercel log drain payload to a local Send2Bucket node writing to S3-compatible storage, and ran the check request and the DuckDB queries (DuckDB 2.0) on the objects it wrote. The Vercel dashboard steps follow Using Drains and were not run against Vercel.
How it works
Vercel ──JSON or NDJSON──▶ /v1/events/vercel ──▶ your stream's destination
- Each log line becomes one record with
signallog, kept as Vercel sent it:id,source,level,message,path,statusCode, theproxyobject and the rest. Delivery format describes the line. - A
200means the records are stored durably and will be delivered at least once. See Delivery semantics. - Drains need a Vercel Pro or Enterprise plan, and Vercel bills drained data by the GB.
1. Create a stream and a key
Create an ingestion stream in the dashboard, add a destination, and copy the stream's API key and ID. A key for one stream needs no stream ID in the drain.
2. Add the drain
Vercel drains can send custom headers, so the key goes in Authorization.
-
In your Vercel team's settings, open Drains and add a drain with the Logs data type and a custom endpoint.
-
Endpoint:
https://api.send2bucket.com/v1/events/vercel. Either format, JSON or NDJSON, works. -
Custom headers, one per line:
Authorization: Bearer <key>S2b-Stream: <stream_id>Leave out
S2b-Streamif the key writes to one stream.
Vercel tests the endpoint when you save the drain; the test needs the key to be valid. Send2Bucket does not check x-vercel-signature, so the key header is what authenticates the drain.
3. Check the endpoint
Before Vercel sends anything, check the key and stream with one request. It stores one record, and the answer is a 200 with an empty body:
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 lists every error.
4. Query the logs
DuckDB reads the objects in place. This view keeps the drained logs:
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';
Errors by source and path:
SELECT data->>'$.source' AS source, data->>'$.path' AS path, count(*) AS errors
FROM drains
WHERE data->>'$.level' IN ('error', 'fatal')
GROUP BY ALL
ORDER BY errors DESC;
Paths that answered with a server error. proxy.statusCode is the status of the request Vercel served; build logs have no proxy, and background regeneration reports -1:
SELECT data->>'$.proxy.path' AS path,
(data->>'$.proxy.statusCode')::INTEGER AS status,
count(*) AS requests
FROM drains
WHERE (data->>'$.proxy.statusCode')::INTEGER >= 500
GROUP BY ALL
ORDER BY requests DESC;
Function invocations that crashed without a response have statusCode -1:
SELECT received_at, data->>'$.path' AS path, data->>'$.message' AS message
FROM drains
WHERE data->>'$.source' = 'lambda' AND (data->>'$.statusCode')::INTEGER = -1
ORDER BY received_at DESC
LIMIT 20;
In an Iceberg or DuckLake table, the same line is in the payload column with signal_type log; see Table columns.
Notes
- Size: Vercel sends up to 1 MB per request; a request can be up to 8 MiB decompressed.
- Billing: each record's JSON as stored is the number billed. See Plans and billing.
- Retries: Vercel's retries are not deduplicated. To drop repeats, key on Vercel's
idin your query. See Retries. - Other platforms: Log drains covers Heroku, Supabase, Netlify, Cloudflare, Fastly and others.