Using Drains

Drains are available on Enterprise and Pro plans

You can add drains to your project by configuring any data type to send to custom HTTP endpoints or for Log Drains, by using integrations to popular services.

Teams on Pro and Enterprise plans can configure custom drains to forward observability data to HTTP endpoints without installing or creating an integration. This allows you to send logs, traces, speed insights, and analytics data to any service that accepts HTTP requests.

  1. From the Vercel dashboard, go to Team Settings > Drains and click Add Drain. Select Custom HTTP endpoint from the dropdown menu.

  2. Select the type of observability data you want to drain:

    • Logs: Runtime, build and static logs from your deployments
    • Traces: Distributed tracing data using OpenTelemetry Protocol
    • Speed Insights: Performance metrics and web vitals
    • Web Analytics: Page views and custom events
  3. 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.

    Configure the sampling rate to control the volume of data sent to your drain. This can help manage costs when you have high traffic volumes.

    If you selected logs as your data type, you can also configure:

    Sources - Select which log sources to collect:

    • 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

    Environments - Select which environments to drain from:

  4. This is the URL of the endpoint we will send your data to. The request will be sent over HTTPS using the POST method. Make sure your endpoint responds with a 200 OK status code.

    Choose the delivery format based on your data type:

    You can secure your endpoint by comparing the x-vercel-signature header with this secret. See Securing your Drains for implementation details.

    A secret will be automatically generated for you, and you can change it and provide your own secret at any time.

    Add custom headers for authentication, identification, or routing purposes. Common use cases include:

    • Authentication: Bearer tokens, API keys, or custom auth headers
    • Routing: Headers to route requests to specific services or regions
    • Identification: Custom headers to identify the source or type of data
    • Content negotiation: Headers to specify preferred response formats

    Format headers as Header-Name: Header-Value with one header per line.

  5. Once you have configured all settings, click Create Drain. Your endpoint will be tested automatically when you create the drain, and Vercel will immediately start forwarding data to your endpoint based on your configuration.

    You can also test your endpoint anytime by clicking the Test button to ensure your endpoint receives the data correctly.

Vercel automatically correlates logs with distributed traces when using OpenTelemetry. Any logs generated during traced requests are enriched with correlation identifiers:

  • traceId - The trace identifier
  • spanId - The span identifier

This correlation happens automatically without code changes. For example, this log:

console.log('User logged in', { userId: 123 });

Will be automatically enriched with trace and span identifiers.

Limitations: Only applies to user code logs during traced requests, not build-time logs.

You can create Drains with Integrations. Integrations are available for log data only and provide a managed configuration experience. The Integrations Marketplace has numerous logging services for you to integrate with.

To create a new Drain from an Integration, follow these steps:

  1. From the Vercel dashboard, go to Team Settings > Drains and click Add Drain.
  2. Select Integrations from the dropdown menu.
  3. Select the Integration you want to use and click Continue.
  4. Follow the configuration steps provided and choose a project to connect with the service.
  5. Watch your logs appear on the selected service.

Occasionally your drain endpoints can return an error. If more than 80% of drain deliveries fail or the number of failures exceed 50 for the past hour, we will send a notification email and indicate the error status on your Drains page.

Errored drain will show a warning status.
Errored drain will show a warning status.
  1. From your team's dashboard, select the Settings tab
  2. Select Drains from the sidebar
  3. In available Drains, click on the menu on the right and click Pause to pause a drain or Resume to resume it
  4. In available Drains, click on the menu on the right and click Delete to delete a drain

For more information on Drains and how to use them, check out the following resources: