add-prometheus-metric

Adds new Prometheus metrics to a Next.js dashboard across BFF routes, React Query, i18n, and UI components.

11|Updated Apr 30, 2026
One-click install
npx skills add https://github.com/scitix/Agent-Sandbox --skill add-prometheus-metric-scitix
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: add-prometheus-metric
Source: https://github.com/scitix/Agent-Sandbox/tree/main/dashboard/.claude/skills/add-prometheus-metric
Command: npx skills add https://github.com/scitix/Agent-Sandbox --skill add-prometheus-metric-scitix

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Adding a new Prometheus metric to the agentbox dashboard requires touching four separate layers (BFF API route, type definitions, React Query options, i18n keys, and UI components), and missing any step or misusing PromQL patterns leads to broken charts, type errors, or inconsistent data. ## Core Features & Use Cases - Full-stack recipe: Step-by-step instructions covering the Next.js BFF route, TypeScript response types, queryOptions, i18n keys, and AdminMetricsSection integration. - Instant vs time series guidance: Decision table and code templates for stat cards (instant queries with increase()) versus charts (range queries with rate() or histogram_quantile()). - PromQL conventions: Enforced rate-window ladder, selector building cheatsheet (buildClusterMatcher vs buildSelector), and per-query error isolation with .catch(() => null). - Use Case: When asked to "add a bandwidth metric card", follow the recipe to create the envoy-bandwidth route, add MyMetricData types, wire queryOptions, add i18n strings, and render a StatCard, then verify with pnpm exec tsc --noEmit. ## Quick Start Add a new Prometheus stat card to the dashboard showing total requests over the selected time range, following the full-stack recipe from BFF route to UI component.

Frequently Asked Questions about add-prometheus-metric

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add a new Prometheus metric to a Next.js dashboard?

Create a BFF route under app/api/prometheus using withPrometheusRoute, add a response type in lib/types/prometheus.ts, define queryOptions in lib/queries/prometheus.ts, add i18n keys to messages/en.json, and render a StatCard or MetricsChart in the AdminMetricsSection component.

When should I use an instant query versus a range query in PromQL?

Use instant queries with increase() for single-number stat cards like cumulative totals, and range queries with rate() or histogram_quantile() for time series charts. For metrics needing both, create two separate routes as done with envoy-bandwidth and envoy-bandwidth-rate.

How do I choose the correct rate window for PromQL range queries?

Never hard-code windows like [5m]; interpolate the rateWindow from timeRange, which follows the rule window = max(2 × step, 1m). The window grows with the selected time range, from 1 minute for short ranges up to 1 day for ranges over 30 days.

What is the difference between buildClusterMatcher and buildSelector?

buildClusterMatcher filters only by cluster and suits Envoy or infrastructure metrics without team or user labels. buildSelector includes cluster, team, user, and pool filters and is used for user-scoped sandbox metrics.

Why does one failed Prometheus query break my entire dashboard chart?

It breaks when queries are not individually guarded. Append .catch(() => null) to each fetchPrometheusInstant or fetchPrometheusRange call so a single failing query returns null instead of rejecting the whole Promise.all and breaking sibling metrics.