Skip to content
vercel-observability logo

Vercel Observability

vercel-observability

Set up Vercel observability with runtime logs, analytics, log drains,

SKILL.md

Full skill instructions

Vercel Observability

Overview

Configure comprehensive observability for Vercel deployments using built-in analytics, runtime logs, log drains to external providers, OpenTelemetry integration, and custom instrumentation. Covers the full observability stack from function-level metrics to end-user experience monitoring.

Prerequisites

  • Vercel Pro or Enterprise plan (for log drains and extended retention)
  • External logging provider (Datadog, Axiom, Sentry) — optional
  • OpenTelemetry SDK — optional

Instructions

Step 1: Enable Vercel Analytics

In the Vercel dashboard:

  1. Go to Analytics tab
  2. Enable Web Analytics (Core Web Vitals, page views)
  3. Enable Speed Insights (real user performance data)
// For Next.js — add the analytics component
// src/​app/​layout.tsx
import { Analytics } from '@vercel/​analytics/​react';
import { SpeedInsights } from '@vercel/​speed-insights/​next';

export default function RootLayout({ children }) {
  return (
    <html>
      <body>
        {children}
        <Analytics />
        <SpeedInsights />
      </​body>
    </​html>
  );
}

Install: npm install @vercel/​analytics @vercel/​speed-insights

Step 2: Runtime Logs

# View runtime logs via CLI
vercel logs https://my-app.vercel.app --follow

# Filter by level
vercel logs https://my-app.vercel.app --level=error

# View logs via API
curl -s -H "Authorization: Bearer $VERCEL_TOKEN" \
  "https://api.vercel.com/​v2/​deployments/​dpl_xxx/​events?limit=50&direction=backward" \
  | jq '.[] | {timestamp: .created, level: .level, message: .text}'

Runtime logs include:

  • Function invocation start/​end with duration
  • console.log/​warn/​error output from functions
  • Edge Middleware execution logs
  • HTTP request/​response metadata

Step 3: Structured Logging in Functions

// lib/​logger.ts — structured JSON logging
interface LogEntry {
  level: 'info' | 'warn' | 'error';
  message: string;
  requestId?: string;
  duration?: number;
  [key: string]: unknown;
}

export function log(entry: LogEntry): void {
  // Vercel captures console output as runtime logs
  const output = JSON.stringify({
    ...entry,
    timestamp: new Date().toISOString(),
    region: process.env.VERCEL_REGION,
    env: process.env.VERCEL_ENV,
  });

  switch (entry.level) {
    case 'error': console.error(output); break;
    case 'warn': console.warn(output); break;
    default: console.log(output);
  }
}

// Usage in API route:
export async function GET(request: Request) {
  const requestId = crypto.randomUUID();
  const start = Date.now();

  try {
    const data = await fetchData();
    log({ level: 'info', message: 'Fetched data', requestId, duration: Date.now() - start });
    return Response.json(data);
  } catch (error) {
    log({ level: 'error', message: 'Data fetch failed', requestId, error: String(error) });
    return Response.json({ error: 'Internal error', requestId }, { status: 500 });
  }
}

Step 4: Log Drains (External Providers)

Configure log drains to send all Vercel logs to your logging provider:

In dashboard: Settings > Log Drains > Add

Supported providers:

ProviderTypeSetup
DatadogHTTPAPI key + site URL
AxiomHTTPAPI token + dataset
SentryHTTPDSN
CustomHTTP/​NDJSONAny HTTPS endpoint
Grafana LokiHTTPPush URL + auth

Log drain delivers:

  • Runtime logs: function invocations, console output
  • Build logs: build step output, warnings, errors
  • Static logs: CDN access logs (edge)
  • Firewall logs: WAF events
# Create a log drain via API
curl -X POST "https://api.vercel.com/​v2/​integrations/​log-drains" \
  -H "Authorization: Bearer $VERCEL_TOKEN" \
  -H "Content-Type: application/​json" \
  -d '{
    "name": "my-datadog-drain",
    "type": "json",
    "url": "https://http-intake.logs.datadoghq.com/​api/​v2/​logs",
    "headers": {"DD-API-KEY": "your-datadog-api-key"},
    "sources": ["lambda", "edge", "build", "static"]
  }'

Step 5: OpenTelemetry Integration

// instrumentation.ts (Next.js 13.4+)
import { NodeSDK } from '@opentelemetry/​sdk-node';
import { OTLPTraceExporter } from '@opentelemetry/​exporter-trace-otlp-http';
import { getNodeAutoInstrumentations } from '@opentelemetry/​auto-instrumentations-node';

export function register() {
  const sdk = new NodeSDK({
    traceExporter: new OTLPTraceExporter({
      url: process.env.OTEL_EXPORTER_OTLP_ENDPOINT,
    }),
    instrumentations: [getNodeAutoInstrumentations()],
    serviceName: 'my-vercel-app',
  });
  sdk.start();
}
// next.config.js
module.exports = {
  experimental: {
    instrumentationHook: true,
  },
};

Step 6: Error Tracking with Sentry

npx @sentry/​wizard@latest -i nextjs
// sentry.client.config.ts
import * as Sentry from '@sentry/​nextjs';

Sentry.init({
  dsn: process.env.NEXT_PUBLIC_SENTRY_DSN,
  environment: process.env.VERCEL_ENV,
  release: process.env.VERCEL_GIT_COMMIT_SHA,
  tracesSampleRate: process.env.VERCEL_ENV === 'production' ? 0.1 : 1.0,
});

Monitoring Dashboard Checklist

MetricSourceAlert Threshold
Error rateRuntime logs> 1% of requests
P95 function latencyVercel Analytics> 2s
Cold start frequencyRuntime logs> 20% of invocations
Build success rateBuild logsAny failure
Core Web Vitals (LCP)Speed Insights> 2.5s
Edge cache hit rateStatic logs< 80%

Output

  • Vercel Analytics and Speed Insights enabled
  • Structured JSON logging in all functions
  • Log drains configured to external provider
  • Error tracking with Sentry or equivalent
  • OpenTelemetry tracing for distributed systems

Error Handling

ErrorCauseSolution
Logs missingLog retention expired (1hr free, 30d with Plus)Enable log drains for persistence
Analytics not trackingMissing <Analytics /> componentAdd to root layout
Log drain not receivingWrong URL or auth headersTest the endpoint directly with curl
Sentry not capturing errorsDSN not set in production envAdd NEXT_PUBLIC_SENTRY_DSN to Production scope
OTEL traces missinginstrumentation.ts not loadedEnable instrumentationHook in next.config.js

Resources

Next Steps

For incident response, see vercel-incident-runbook.

More skills from jeremylongshore

openrouter-compliance-review logo
jeremylongshore/claude-code-plugins-plus-skills

openrouter-compliance-review

Review OpenRouter integration for regulatory compliance (SOC2, GDPR,

2.8K 0
View
maintainx-data-handling logo
jeremylongshore/claude-code-plugins-plus-skills

maintainx-data-handling

Data synchronization, ETL patterns, and data management for MaintainX.

2.8K 0
View
groq-core-workflow-a logo
jeremylongshore/claude-code-plugins-plus-skills

groq-core-workflow-a

Execute Groq primary workflow: chat completions with tool use and JSON

2.8K 0
View
validating-csrf-protection logo
jeremylongshore/claude-code-plugins-plus-skills

validating-csrf-protection

Validate CSRF protection implementations for security gaps. Use when

2.8K 0
View
api-contract logo
jeremylongshore/claude-code-plugins-plus-skills

api-contract

Configure this skill should be used when the user asks about "API contract",

2.8K 0
View
ideogram-incident-runbook logo
jeremylongshore/claude-code-plugins-plus-skills

ideogram-incident-runbook

Execute Ideogram incident response with triage, mitigation, and postmortem.

2.8K 0
View
gamma-sdk-patterns logo
jeremylongshore/claude-code-plugins-plus-skills

gamma-sdk-patterns

Reusable patterns for the Gamma REST API (no SDK exists).

2.8K 0
View
deepgram-sdk-patterns logo
jeremylongshore/claude-code-plugins-plus-skills

deepgram-sdk-patterns

Apply production-ready Deepgram SDK patterns for TypeScript and Python.

2.8K 0
View
openrouter-upgrade-migration logo
jeremylongshore/claude-code-plugins-plus-skills

openrouter-upgrade-migration

Migrate to OpenRouter from direct provider APIs or upgrade between SDK/model

2.8K 0
View
openrouter-common-errors logo
jeremylongshore/claude-code-plugins-plus-skills

openrouter-common-errors

Diagnose and fix common OpenRouter API errors. Use when encountering

2.8K 0
View
linear-cost-tuning logo
jeremylongshore/claude-code-plugins-plus-skills

linear-cost-tuning

Optimize Linear API usage, reduce unnecessary calls, and maximize

2.8K 0
View

Popular AI tools

Kaiber logo
Video

Kaiber

Generate, edit, and beat-sync AI video with leading models in one workspace.

Paid
View
Vimcal logo
Productivity

Vimcal

The world's fastest calendar for remote work

Free
View

Transform Your Design with AI Designer by ImgCreator.ai

Freemium
View
Akool AI logo
Content & writing

Akool AI

Revolutionizing Video Production with AI-Powered Creativity

Paid
View

Extend an image past the frame and let AI fill the new aspect ratio.

Freemium
View
StarByFace logo
Security

StarByFace

Discover your celebrity doppelgänger with StarByFace!

Free
View
C

ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.

Freemium
View
Opus Clip logo
Coding & apps

Opus Clip

Opus.ai: Revolutionize Your Web Experience

Free
View