Send Vercel log drains to Tinybird¶
Vercel is a platform for building and deploying web applications. By integrating Vercel with Tinybird, you can analyze your Vercel events in real time and enrich it with other data sources.
Some common use cases for sending Vercel logs to Tinybird include:
- Analyze logs from your applications.
- Monitor logs from your applications.
- Create custom analytical dashboards.
- Build an alert system based on logging patterns.
Read on to learn how to send logs from Vercel to Tinybird.
Before you start¶
Before you connect Vercel to Tinybird, ensure:
- You have a Vercel team on the Pro or Enterprise plan. Vercel Drains aren't available on Hobby.
- You have a Tinybird Workspace.
Create the Data Source¶
In your Tinybird project, create a Data Source called vercel_logs:
SCHEMA >
`event_time` DateTime `json:$.tinybirdIngestTime` DEFAULT now(),
`event_type` String `json:$.type` DEFAULT 'unknown',
`event` JSON `json:$` DEFAULT '{}'
ENGINE "MergeTree"
ENGINE_PARTITION_KEY "toYYYYMM(event_time)"
ENGINE_SORTING_KEY "event_time"
The event column stores the full log as JSON. Query nested fields with dot notation, for example event.proxy.path or event.statusCode. See the Vercel logs schema for every field.
Deploy the project and copy a Token with append permissions on the vercel_logs Data Source.
Connect Vercel to Tinybird¶
- In the Vercel dashboard, go to Team Settings > Drains and select Add Drain.
- Select Logs as the data type.
- Name the drain and select the projects, log sources and environments to send. Optionally, add sampling rules.
- Under the destination, select Custom Endpoint and set the format to NDJSON.
- Set the endpoint URL to the Events API, with the
namequery parameter matching your Data Source:
https://<your_host>/v0/events?name=vercel_logs
The API host in the following examples must match your Workspace's region. See the full list of regions and hosts
- Under Custom Headers, add
Authorization: Bearer <your-tinybird-token>. - Select Create Drain. Vercel tests the endpoint when you create the drain, and you can select Test at any time to send sample logs.
If Vercel asks you to verify ownership of the endpoint with an x-vercel-verify value, add x-vercel-verify=<value> to the endpoint URL as a second query parameter. The Events API returns the value in the x-vercel-verify response header.
Check that logs arrive from the Log tab of the vercel_logs Data Source in Tinybird Cloud.
Vercel Logs Explorer template¶
Use the Vercel Logs Explorer Template to bootstrap a multi-tenant, user-facing logs explorer for your Vercel account. You can fork it and make it your own. The template uses its own logs Data Source with typed columns, so point the drain at /v0/events?name=logs when you use it.