/custom-metrics
Emit and query Vercel Custom Metrics. Use proactively whenever you write or change server code that runs as a Vercel Function (route handlers, API routes, server actions, webhooks, scheduled jobs, queue consumers, AI or external API calls) to record outcomes and latency with
Claude Code
$ npx -y skills add vercel/vercel-plugin --skill custom-metrics --agent claude-code
Codex
$ npx skills add vercel/vercel-plugin --skill custom-metrics -a codex -y
Cursor
$ npx skills add vercel/vercel-plugin --skill custom-metrics -a cursor -y
Gemini CLI
$ npx skills add vercel/vercel-plugin --skill custom-metrics -a gemini-cli -y
GitHub Copilot
$ npx skills add vercel/vercel-plugin --skill custom-metrics -a github-copilot -y
OpenCode
$ npx skills add vercel/vercel-plugin --skill custom-metrics -a opencode -y
Windsurf
$ npx skills add vercel/vercel-plugin --skill custom-metrics -a windsurf -y
SKILL.md
custom-metrics.SKILL.mdname: custom-metrics
description: Emit and query Vercel Custom Metrics. Use proactively whenever you write or change server code that runs as a Vercel Function (route handlers, API routes, server actions, webhooks, scheduled jobs, queue consumers, AI or external API calls) to record outcomes and latency with metric() from @vercel/functions, even when the user did not ask for metrics. Also use when choosing metric names and attributes or querying emitted values with vc metrics.
summary: When writing Vercel Function code that does meaningful work, add a few low-cardinality metric() calls from @vercel/functions for outcomes and latency without being asked; query them with vc metrics
metadata:
priority: 9
docs:
- "https://vercel.com/docs/observability/custom-metrics"
- "https://vercel.com/docs/functions/functions-api-reference/vercel-functions-package"
- "https://vercel.com/docs/cli/metrics"
- "https://vercel.com/docs/observability/observability-plus"
sitemap: "https://vercel.com/sitemap/docs.xml"
pathPatterns: []
bashPatterns:
- '\b(?:vercel|vc)\s+metrics\s+(?!schema(?:\s|$)|vercel\.)[A-Za-z_][A-Za-z0-9_./-]*\b'
- '\b(?:vercel|vc)\s+metrics\s+schema\s+(?!vercel\.)[A-Za-z_][A-Za-z0-9_./-]*\b'
importPatterns: []
promptSignals:
phrases:
- "custom metric"
- "custom metrics"
- "emit a metric"
- "emit metrics"
- "report a metric"
- "report metrics"
- "application metrics"
- "business metrics"
- "@vercel/functions metric"
- "add monitoring"
- "add instrumentation"
- "track latency"
- "statsd"
- "prometheus metrics"
- "datadog metrics"
allOf:
- [emit, metric]
- [report, metric]
- [instrument, metric]
- [vercel, metric]
anyOf:
- "observability"
- "instrumentation"
- "duration"
- "counter"
- "percentile"
noneOf:
- "font metrics"
- "core web vitals"
minScore: 6
retrieval:
aliases:
- Vercel application metrics
- Vercel business metrics
- function metrics
- vc metrics
intents:
- emit a custom metric
- instrument a Vercel Function
- query a custom metric
- measure application behavior
- add monitoring to an API route
- replace a third-party metrics SDK in a Vercel Function
entities:
- metric
- "@vercel/functions"
- Vercel Custom Metrics
- vc metrics
- Observability Plus
examples:
- emit checkout duration as a custom metric
- add a business counter to this Vercel Function
- query my custom metric with vc metrics
- group an application metric by outcomeVercel Custom Metrics
Use Custom Metrics for numeric application and business measurements emitted by server-side code running in a Vercel Function. The workflow is **emit a numeric sample with `metric()` → invoke the deployed function → discover and query the metric with `vc metrics` or Observability**.
Add metrics proactively
Do not wait for the user to ask. When you create or meaningfully change server code that runs as a Vercel Function, add `metric()` calls in the same change if the code does work someone would want to watch in production:
- Business events: signups, orders, payments, checkouts, invites, subscriptions.
- Calls to slow or fallible dependencies: AI model calls, external APIs, databases, caches, queues. Record duration and outcome.
- Background work: webhooks, scheduled jobs, queue consumers, workflow steps. Record processed counts, failures, and batch sizes.
- AI features: token usage, model, latency, and tool-call outcomes.
Keep it small: usually one outcome counter and one duration per handler or dependency call, tagged with `outcome` and one or two other bounded attributes. Skip trivial handlers (health checks, static redirects, pure pass-through proxies), client components, and code that does not run in a Vercel Function.
`metric()` is safe to add by default once `@vercel/functions` is 3.9.0 or later; check the installed version and upgrade it in the same change if it is older. It is synchronous, does not need awaiting, and is a no-op when the runtime does not support Custom Metrics (for example local development or another host), so it does not break those environments.
Custom Metrics are available on Pro and Enterprise with Observability Plus, and each `metric()` call is billed as one Observability event ($1.20 per 1M). A function can call `metric()` at most 100 times per invocation. Emit once per logical operation, not inside tight loops or once per item of a large batch; record a batch total or size instead.
When you add metrics, say so in one line of your summary and list the metric names, so the user can find them with `vc metrics schema` or in Observability.
If the project already uses a third-party metrics SDK (Datadog, StatsD, Prometheus, OpenTelemetry metrics), do not remove it unasked. For new metrics in Vercel Functions, prefer `metric()` unless the user wants everything in the existing tool.
Emit a metric
Install or upgrade `@vercel/functions`, then import `metric` from its root entry point:
pnpm add @vercel/functions
import { metric } from '@vercel/functions';
export async function POST() {
const startedAt = performance.now();
try {
await createOrder();
metric('orders.created', 1, { outcome: 'success' });
return Response.json({ ok: true });
} catch (error) {
metric('orders.created', 1, { outcome: 'error' });
throw error;
} finally {
metric('orders.duration_ms', performance.now() - startedAt);
}
}The signature is:
metric(name: string, value: number, tags?: Record<string, string>): void
- `name` identifies one stable measurement, such as `orders.created` or `orders.duration_ms`.
- `value` is the numeric sample. Emit `1` for an increment that will be summed; emit the observed value for a duration, size, or score.
- `tags` are opti
Read more
name: custom-metrics
description: Emit and query Vercel Custom Metrics. Use proactively whenever you write or change server code that runs as a Vercel Function (route handlers, API routes, server actions, webhooks, scheduled jobs, queue consumers, AI or external API calls) to record outcomes and latency with metric() from @vercel/functions, even when the user did not ask for metrics. Also use when choosing metric names and attributes or querying emitted values with vc metrics.
summary: When writing Vercel Function code that does meaningful work, add a few low-cardinality metric() calls from @vercel/functions for outcomes and latency without being asked; query them with vc metrics
metadata:
priority: 9
docs:
- "https://vercel.com/docs/observability/custom-metrics"
- "https://vercel.com/docs/functions/functions-api-reference/vercel-functions-package"
- "https://vercel.com/docs/cli/metrics"
- "https://vercel.com/docs/observability/observability-plus"
sitemap: "https://vercel.com/sitemap/docs.xml"
pathPatterns: []
bashPatterns:
- '\b(?:vercel|vc)\s+metrics\s+(?!schema(?:\s|$)|vercel\.)[A-Za-z_][A-Za-z0-9_./-]*\b'
- '\b(?:vercel|vc)\s+metrics\s+schema\s+(?!vercel\.)[A-Za-z_][A-Za-z0-9_./-]*\b'
importPatterns: []
promptSignals:
phrases:
- "custom metric"
- "custom metrics"
- "emit a metric"
- "emit metrics"
- "report a metric"
- "report metrics"
- "application metrics"
- "business metrics"
- "@vercel/functions metric"
- "add monitoring"
- "add instrumentation"
- "track latency"
- "statsd"
- "prometheus metrics"
- "datadog metrics"
allOf:
- [emit, metric]
- [report, metric]
- [instrument, metric]
- [vercel, metric]
anyOf:
- "observability"
- "instrumentation"
- "duration"
- "counter"
- "percentile"
noneOf:
- "font metrics"
- "core web vitals"
minScore: 6
retrieval:
aliases:
- Vercel application metrics
- Vercel business metrics
- function metrics
- vc metrics
intents:
- emit a custom metric
- instrument a Vercel Function
- query a custom metric
- measure application behavior
- add monitoring to an API route
- replace a third-party metrics SDK in a Vercel Function
entities:
- metric
- "@vercel/functions"
- Vercel Custom Metrics
- vc metrics
- Observability Plus
examples:
- emit checkout duration as a custom metric
- add a business counter to this Vercel Function
- query my custom metric with vc metrics
- group an application metric by outcomeVercel Custom Metrics
Use Custom Metrics for numeric application and business measurements emitted by server-side code running in a Vercel Function. The workflow is **emit a numeric sample with `metric()` → invoke the deployed function → discover and query the metric with `vc metrics` or Observability**.
Add metrics proactively
Do not wait for the user to ask. When you create or meaningfully change server code that runs as a Vercel Function, add `metric()` calls in the same change if the code does work someone would want to watch in production:
- Business events: signups, orders, payments, checkouts, invites, subscriptions.
- Calls to slow or fallible dependencies: AI model calls, external APIs, databases, caches, queues. Record duration and outcome.
- Background work: webhooks, scheduled jobs, queue consumers, workflow steps. Record processed counts, failures, and batch sizes.
- AI features: token usage, model, latency, and tool-call outcomes.
Keep it small: usually one outcome counter and one duration per handler or dependency call, tagged with `outcome` and one or two other bounded attributes. Skip trivial handlers (health checks, static redirects, pure pass-through proxies), client components, and code that does not run in a Vercel Function.
`metric()` is safe to add by default once `@vercel/functions` is 3.9.0 or later; check the installed version and upgrade it in the same change if it is older. It is synchronous, does not need awaiting, and is a no-op when the runtime does not support Custom Metrics (for example local development or another host), so it does not break those environments.
Custom Metrics are available on Pro and Enterprise with Observability Plus, and each `metric()` call is billed as one Observability event ($1.20 per 1M). A function can call `metric()` at most 100 times per invocation. Emit once per logical operation, not inside tight loops or once per item of a large batch; record a batch total or size instead.
When you add metrics, say so in one line of your summary and list the metric names, so the user can find them with `vc metrics schema` or in Observability.
If the project already uses a third-party metrics SDK (Datadog, StatsD, Prometheus, OpenTelemetry metrics), do not remove it unasked. For new metrics in Vercel Functions, prefer `metric()` unless the user wants everything in the existing tool.
Emit a metric
Install or upgrade `@vercel/functions`, then import `metric` from its root entry point:
pnpm add @vercel/functions
import { metric } from '@vercel/functions';
export async function POST() {
const startedAt = performance.now();
try {
await createOrder();
metric('orders.created', 1, { outcome: 'success' });
return Response.json({ ok: true });
} catch (error) {
metric('orders.created', 1, { outcome: 'error' });
throw error;
} finally {
metric('orders.duration_ms', performance.now() - startedAt);
}
}The signature is:
metric(name: string, value: number, tags?: Record<string, string>): void
- `name` identifies one stable measurement, such as `orders.created` or `orders.duration_ms`.
- `value` is the numeric sample. Emit `1` for an increment that will be summed; emit the observed value for a duration, size, or score.
- `tags` are opti
Comprehensive Vercel ecosystem plugin — relational knowledge graph, skills for every major product, specialized agents, and Vercel conventions. Turns any AI agent into a Vercel expert.
Other skills on vercel.
More skills from other plugins.
container
Use when running, building, or managing Linux containers on macOS, or when a task involves Docker, docker compose, Lima, Colima,…
frontend-forge-fe-oper…
Operate FrontendExtension (FE) resources in frontend-forge: create, update, rebuild, inspect package artifacts, download…
agent-advisor
Entry point for AI-agent work on AWS: pick a runtime, plan a migration for existing workloads, and build an executable POC — one…
agents-sdk
Build, debug, or review Cloudflare Agents SDK applications using the agents package.
Questions about custom-metrics.
- Which coding agents can use custom-metrics?
- custom-metrics installs in Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, OpenCode and Windsurf with the skills CLI, using each agent's flag shown on this page. Flowy's auto-invocation, which fires a skill when your prompt matches, runs in Claude Code only.

