How-to
3 min read

Configure Log Drains

Subscribe to log drains that are generic and configurable from the Vercel dashboard without creating an integration.
Table of Contents

Log drains are available on Pro and Enterprise plans

Teams on Pro and Enterprise plans can subscribe to log drains that are generic and configurable from the Vercel dashboard without creating an integration. This allows you to use a HTTP service to receive logs through Vercel's log drains.

  1. From the Vercel dashboard, go to Team Settings > Log Drains.

  2. Choose the scope of project(s) to collect log drains.
    Choose the scope of project(s) to collect log drains.

    Choose the scope of team projects for which logs will be collected. You can do it for all or some specific projects based on your requirements.

  3. Select one or more sources to collect log drains.
    Select one or more sources to collect log drains.

    The log data is typically collected from various sources, which will be forwarded to your webhook over a network connection. Make sure you select one of these sources when you add a new log drain:

    • Static: Collect logs for static assets like HTML and CSS files
    • Edge: Outputs log data from Edge Functions like Middleware
    • Lambda: Outputs log data from Vercel Functions like API Routes
    • External: Collect log results for external rewrites to a different domain
    • Build: Outputs log data from the Build Step
  4. Select the mode that decides the format in which your log data gets delivered. You can to choose from the following format types:

    • JSON: With the JSON format, the URL receives a HTTPS or HTTP request with a JSON array on the POST body.
    • NDJSON: With the Newline Delimited JSON (NDJSON) format, the URL receives a HTTPS or HTTP POST request with JSON objects delimited by newline (\\n) on the HTTP POST body.

    Vercel supports two formats of Log drains. You can read and learn more about these here .

  5. Input optional custom secret string.
    Input optional custom secret string.

    After deciding the format, you can optionally input your custom secret which is required to be at least 32 characters.

  6. Select one or more environment to collect logs.
    Select one or more environment to collect logs.

    You can collect logs from production or preview environment. Make sure to select at least one.

  7. Select the log sampling rate.
    Select the log sampling rate.

    You can select a sampling rate, at the percentage of which logs will be randomly collected.

  8. Define the endpoint URL for the log drains.
    Define the endpoint URL for the log drains.

    The log drains endpoint acts as the destination for your logs and is provided by the provider ingesting the log drains. All logs data will be forwarded to this URL as a POST request. Once added, Vercel asks you to "Verify" the endpoint. The purpose is to validate the URL ownership that responds with a status code 200 with a header. For example:

    x-vercel-verify: f20eab3717014bdb9e7b9876789ea974c46bce5ce

    If you are unable to complete the endpoint verification step, it's recommended to contact Vercel support team.

    The verification code is different for each team.

    Add custom headers to protect your endpoint URLs.
    Add custom headers to protect your endpoint URLs.

    You can optionally add up to 5 custom headers to your log drains URL.

    For example, a commonly required header is your Vercel authentication token as an authorization header (i.e., Authorization: Bearer[TOKEN] ).

    Other required headers for known providers:

    • Dynatrace: Content-Type: application/json; charset=utf-8
  9. Once you have set up the log drains and specified the endpoint URL, click the "Add Log Drain" button, and Vercel will start sending logs to the log drain whenever your application generates them.

    You can also click the "Test Log Drain" button to trigger a sample log (corresponding to the selected source(s)) to the target endpoint, so you can ensure the configuration is correct even before adding the log drain.

  10. View your active log drain list.
    View your active log drain list.

    After the endpoint is confirmed and successfully verified, the logs will start to flow and appear in your Active log drains list. While in beta, you can create and use up to 5 custom log drains at one time.

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

Last updated on June 15, 2024