Vercel Drains

Learn how to set up Vercel drains to forward logs and traces data to Sentry.

Vercel Drains let you forward traces and logs from applications running on Vercel to Sentry. For more information on Vercel Drains, see the Vercel drain documentation. Currently only Logs and Traces are supported.

  • Logs: Runtime, build, and static logs from your deployments
  • Traces: Distributed tracing data collected via OpenTelemetry (OTLP) from your applications

Before you begin, ensure you have:

  • A Vercel pro or higher plan and project that you want to monitor
  • A Sentry project you want to send data to

If you've installed the Sentry Vercel Integration, you can set up a drain via the integration.

If you haven't installed the integration, you can follow the instructions in the Sentry Vercel Integration documentation to install the integration.

Then you can add a Drain from your Vercel team's Integrations tab.

  1. From the Vercel dashboard, view the integrations list by clicking the Integrations tab.
  2. Select the Sentry integration from the integrations list to view the integration settings.
  3. Click Manage and select your installed product
  4. Under Drains, click Add Drain to create a new drain.
  5. Configure which project you would like to send data from and click Create Drain to create the drain.

To set up a Drain in Vercel manually, you'll need to create a new Drain in the Vercel settings.

  1. From the Vercel dashboard, go to Team Settings > Drains and click Add Drain.
  2. Choose a data type.

After selecting the Logs data type, you'll need to configure the drain to send data to Sentry.

  1. Provide a name for your drain and select which projects should send data to your endpoint. You can choose all projects or select specific ones.

  2. Configure the sampling rate to control the volume of data sent to your drain. We recommend sampling 100% of the data to ensure you get all the data you need.

  3. Select which log sources to collect. See Log Source Details for more information.

  4. Select which environments to drain from. You can choose to drain from all environments or select specific ones.

  5. Under the custom endpoint tab add the Sentry Vercel Log Drain Endpoint in the URL field. You can find the endpoint in your Sentry Project Settings under Client Keys (DSN) > Vercel. You can select either JSON or NDJSON encoding.

Copied
___VERCEL_LOG_DRAIN_URL___
  1. Click the Custom Headers toggle and add the Sentry Authentication Header. You'll also find the header value in your Sentry Project Settings under Client Keys (DSN) > Vercel.
Copied
x-sentry-auth: sentry sentry_key=___PUBLIC_KEY___
  1. To test that the log drain is working, you can send a test log to your drain by clicking the Test button.

After selecting the Traces data type, you'll need to configure the drain to send data to Sentry.

  1. Provide a name for your drain and select which projects should send data to your endpoint. You can choose all projects or select specific ones.
  2. Configure the sampling rate to control the volume of data sent to your drain. We recommend sampling 100% of the data to ensure you get all the data you need.
  3. Under the custom endpoint tab add the Sentry Vercel Trace Drain Endpoint in the URL field. You can find the endpoint in your Sentry Project Settings under Client Keys (DSN) > OpenTelemetry (OTLP) under the OTLP Traces Endpoint section.
Copied
___OTLP_TRACES_URL___
  1. Click the Custom Headers toggle and add the Sentry Authentication Header. You'll also find the header value in your Sentry Project Settings under Client Keys (DSN) > OpenTelemetry (OTLP) under the OTLP Traces Endpoint Headers section.
Copied
x-sentry-auth: sentry sentry_key=___PUBLIC_KEY___
  1. To test that the trace drain is working, you can send a test trace to your drain by clicking the Test button.

Logs with empty messages

Some logs from the static or edge source have an empty log message. This is intended behavior, the vercel log drain schema intentionally sets an empty log message for some of these logs.

Logs from `static` source show up in Sentry but not the Vercel dashboard

If you drain logs with source static (Static Files) from Vercel, they will show up in Sentry but not in the Vercel Dashboard. By default the Vercel dashboard does not show these logs.

Trace-connected build logs

Build logs forwarded from Vercel are not trace-connected by default. You can use a combination of the vercel.project_name, vercel.deployment_id, and vercel.build_id fields to grab logs from a specific build.

Vercel Log Drains support the following log sources:

  • Functions: Outputs log data from Vercel Functions like API Routes
  • Edge Functions: Outputs log data from Vercel Functions or Routing Middleware using Edge runtime
  • Static Files: Collects logs for static assets like HTML and CSS files
  • Rewrites: Collects log results for external rewrites to a different domain
  • Builds: Outputs log data from the Build Step
  • Firewall: Outputs log data from requests denied by Vercel Firewall rules

Was this helpful?
Help improve this content
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").