wave_get_stream_metrics
Analyze live stream health with metrics on bitrate, latency, quality, and errors to identify and troubleshoot performance issues over time.
Instructions
Get detailed performance metrics for a stream including bitrate, latency, quality scores, and error rates
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| stream_id | Yes | The UUID of the stream | |
| period | No | Time period for metrics aggregation (default: 24h) | |
| granularity | No | Data point granularity (default: 5m) |
Implementation Reference
- src/tools/analytics.ts:75-87 (handler)Handler function for wave_get_stream_metrics tool. Builds query params for period/granularity, calls GET /api/v1/analytics/streams/{stream_id}/metrics, and returns the response body or error.
async ({ stream_id, period, granularity }) => { const params = new URLSearchParams(); if (period) params.set("period", period); if (granularity) params.set("granularity", granularity); const query = params.toString(); const path = `/api/v1/analytics/streams/${stream_id}/metrics${query ? `?${query}` : ""}`; const res = await waveFetch(path); if (!res.ok) return errorContent(res.status, res.body); return textContent(res.body); }, ); - src/tools/analytics.ts:64-74 (schema)Schema definition for wave_get_stream_metrics accepting stream_id (UUID, required), period (enum: 1h/6h/24h/7d/30d, optional), and granularity (enum: 1m/5m/1h/1d, optional).
{ stream_id: z.string().uuid().describe("The UUID of the stream"), period: z .enum(["1h", "6h", "24h", "7d", "30d"]) .optional() .describe("Time period for metrics aggregation (default: 24h)"), granularity: z .enum(["1m", "5m", "1h", "1d"]) .optional() .describe("Data point granularity (default: 5m)"), }, - src/tools/analytics.ts:61-87 (registration)Registration call: server.tool('wave_get_stream_metrics', ...) within registerAnalyticsTools function.
server.tool( "wave_get_stream_metrics", "Get detailed performance metrics for a stream including bitrate, latency, quality scores, and error rates", { stream_id: z.string().uuid().describe("The UUID of the stream"), period: z .enum(["1h", "6h", "24h", "7d", "30d"]) .optional() .describe("Time period for metrics aggregation (default: 24h)"), granularity: z .enum(["1m", "5m", "1h", "1d"]) .optional() .describe("Data point granularity (default: 5m)"), }, async ({ stream_id, period, granularity }) => { const params = new URLSearchParams(); if (period) params.set("period", period); if (granularity) params.set("granularity", granularity); const query = params.toString(); const path = `/api/v1/analytics/streams/${stream_id}/metrics${query ? `?${query}` : ""}`; const res = await waveFetch(path); if (!res.ok) return errorContent(res.status, res.body); return textContent(res.body); }, ); - src/server.ts:22-24 (registration)registerAnalyticsTools(server) is called from server.ts to register all analytics tools including wave_get_stream_metrics.
registerAnalyticsTools(server); registerBillingTools(server); registerProductionTools(server); - src/tools/analytics.ts:5-19 (helper)waveFetch helper used by the handler to make authenticated HTTP requests to the Wave API.
async function waveFetch( path: string, init?: RequestInit, ): Promise<{ ok: boolean; status: number; body: string }> { const url = `${getBaseUrl()}${path}`; const res = await fetch(url, { ...init, headers: { ...getAuthHeaders(), ...init?.headers, }, }); const body = await res.text(); return { ok: res.ok, status: res.status, body }; }