|
| 1 | +--- |
| 2 | +title: Vercel Log Drains |
| 3 | +description: Forward Vercel runtime, build, and edge logs to Sentry using Vercel's built-in log drain. |
| 4 | +type: tutorial |
| 5 | +summary: Configure a Vercel log or trace drain pointed at Sentry's ingestion endpoint to route Vercel output into Sentry Logs and Traces. |
| 6 | +prerequisites: |
| 7 | + - /start-here/deploy-to-vercel/ |
| 8 | + - /operate/observability/ |
| 9 | +related: |
| 10 | + - /extend/sentry-plugin/ |
| 11 | + - /operate/observability/ |
| 12 | + - /operate/reliability-runbooks/ |
| 13 | +--- |
| 14 | + |
| 15 | +Vercel Drains let you forward telemetry from your Vercel-hosted Junior deployment directly to Sentry without modifying application code. Sentry receives the data as [Logs](https://docs.sentry.io/product/explore/logs/) and [Traces](https://docs.sentry.io/product/explore/trace-explorer/). |
| 16 | + |
| 17 | +Official references: |
| 18 | + |
| 19 | +- [Sentry Vercel Drains documentation](https://docs.sentry.io/product/drains/vercel/) |
| 20 | +- [Vercel Drains documentation](https://vercel.com/docs/drains) |
| 21 | + |
| 22 | +## Prerequisites |
| 23 | + |
| 24 | +- Vercel **Pro or higher** plan (drains require Pro or Enterprise) |
| 25 | +- A deployed Junior project on Vercel |
| 26 | +- A Sentry project to receive the data |
| 27 | + |
| 28 | +## Automatic setup (Sentry native integration) |
| 29 | + |
| 30 | +If you installed Junior from the [Sentry Vercel Integration](https://vercel.com/marketplace/sentry) and created a new Sentry account during that flow, you can add drains directly from the integration settings: |
| 31 | + |
| 32 | +1. From the Vercel dashboard, open the **Integrations** tab. |
| 33 | +2. Select **Sentry** from the list, click **Manage**, and select your installed product. |
| 34 | +3. Under **Drains**, click **Add Drain**. |
| 35 | +4. Choose which Vercel project to drain from, then click **Create Drain**. |
| 36 | + |
| 37 | +> **Note:** Automatic drain setup is only available with the Native Integration when a _new_ Sentry account was created during install. For existing Sentry accounts, follow the manual steps below. |
| 38 | +
|
| 39 | +## Manual setup |
| 40 | + |
| 41 | +Manual setup applies to any Sentry account. You need the Sentry ingestion endpoint and auth header from your project's DSN settings. |
| 42 | + |
| 43 | +### Locate the Sentry endpoint and auth header |
| 44 | + |
| 45 | +1. In Sentry, go to **Settings > Projects > \[your project\] > Client Keys (DSN)**. |
| 46 | +2. Expand the **Vercel** section. |
| 47 | +3. Copy the **Vercel Log Drain Endpoint** URL and the **Authentication Header** value (`x-sentry-auth: sentry sentry_key=<key>`). |
| 48 | + |
| 49 | +### Create the log drain in Vercel |
| 50 | + |
| 51 | +1. From the Vercel dashboard, go to **Team Settings > Drains** and click **Add Drain**. |
| 52 | +2. Select **Logs** as the data type. |
| 53 | +3. Name the drain and select the project(s) to drain from. |
| 54 | +4. Set the **Sampling rate**. Start at 100% to confirm delivery, then reduce as needed. |
| 55 | +5. Select the **Log sources** to collect. See [Log sources](#log-sources) below. |
| 56 | +6. Select which **Environments** to drain (production, preview, or all). |
| 57 | +7. Under the **Custom Endpoint** tab: |
| 58 | + - **URL**: paste the Vercel Log Drain Endpoint from Sentry. |
| 59 | + - **Format**: choose **JSON** or **NDJSON** (both are accepted). |
| 60 | + - Enable **Custom Headers** and add one header per line: |
| 61 | + ``` |
| 62 | + x-sentry-auth: sentry sentry_key=<your-public-key> |
| 63 | + ``` |
| 64 | +8. Click **Create Drain**. Vercel tests the endpoint automatically on save. |
| 65 | +
|
| 66 | +### Verify log drain delivery |
| 67 | +
|
| 68 | +After creating the drain, click **Test** from the drain settings. Then check [Sentry Logs](https://sentry.io/explore/logs/) to confirm entries are arriving. |
| 69 | +
|
| 70 | +## Trace drain setup |
| 71 | +
|
| 72 | +Trace drains forward OpenTelemetry (OTLP) distributed tracing data from Vercel Functions to Sentry. |
| 73 | +
|
| 74 | +1. From the Vercel dashboard, go to **Team Settings > Drains > Add Drain**. |
| 75 | +2. Select **Traces** as the data type. |
| 76 | +3. Name the drain, select projects, and configure the sampling rate. |
| 77 | +4. Under the **Custom Endpoint** tab: |
| 78 | + - **URL**: from Sentry **Settings > Projects > \[your project\] > Client Keys (DSN) > OpenTelemetry (OTLP)**, copy the **OTLP Traces Endpoint**. |
| 79 | + - Enable **Custom Headers** and add: |
| 80 | + ``` |
| 81 | + x-sentry-auth: sentry sentry_key=<your-public-key> |
| 82 | + ``` |
| 83 | + (Find this value under the same **OTLP Traces Endpoint Headers** section.) |
| 84 | +5. Click **Create Drain**. |
| 85 | +
|
| 86 | +Vercel sends trace data over OTLP/HTTP (JSON or Protobuf). OTLP/gRPC is not supported by Vercel drains. |
| 87 | +
|
| 88 | +## Log sources |
| 89 | +
|
| 90 | +Vercel surfaces six log source categories. Select the ones relevant to your deployment: |
| 91 | +
|
| 92 | +| Source | What it captures | |
| 93 | +| --- | --- | |
| 94 | +| **Functions** | Output from Vercel Functions (API Routes) | |
| 95 | +| **Edge Functions** | Output from Edge runtime functions and Middleware | |
| 96 | +| **Static Files** | Requests for static assets (HTML, CSS, etc.) | |
| 97 | +| **Rewrites** | External rewrite results to a different domain | |
| 98 | +| **Builds** | Output from the Vercel build step | |
| 99 | +| **Firewall** | Requests denied by Vercel Firewall rules | |
| 100 | +
|
| 101 | +## Caveats |
| 102 | +
|
| 103 | +- **Metric drains not supported.** Speed Insights and Web Analytics cannot be forwarded to Sentry. See [GitHub issue #103488](https://github.com/getsentry/sentry/issues/103488) if you need this. |
| 104 | +- **Empty messages on `static`/`edge` logs.** Some logs from these sources intentionally have an empty `message` field per the Vercel schema. This is expected. |
| 105 | +- **Static source logs in Sentry only.** Logs with `source: static` show up in Sentry but not in the Vercel dashboard by default; that is a Vercel dashboard display limitation. |
| 106 | +- **Build logs are not trace-connected.** Vercel build logs are forwarded but do not carry trace context. Use `vercel.project_name`, `vercel.deployment_id`, and `vercel.build_id` attributes to correlate build logs with a specific deployment. |
| 107 | +- **Trace correlation for runtime logs.** When [Vercel Tracing](https://vercel.com/docs/tracing) is active, runtime logs during traced requests are automatically enriched with `traceId` and `spanId` fields at no extra configuration cost. |
| 108 | +
|
| 109 | +## Next step |
| 110 | +
|
| 111 | +Use [Observability](/operate/observability/) to build queries against the ingested logs and traces, and [Reliability Runbooks](/operate/reliability-runbooks/) for symptom-driven response playbooks. |
0 commit comments