Skip to main content
Metrics are available at three levels: account, basin, and stream. Each returns time-series or scalar data for the specified metric set.
const now = new Date();
const thirtyDaysAgo = new Date(Date.now() - 30 * 24 * 3600 * 1000);
const sixHoursAgo = new Date(Date.now() - 6 * 3600 * 1000);
const hourAgo = new Date(Date.now() - 3600 * 1000);

// Account-level: active basins over the last 30 days
const accountMetrics = await client.metrics.account({
	set: "active-basins",
	start: thirtyDaysAgo,
	end: now,
});

// Basin-level: storage usage with hourly resolution
const basinMetrics = await client.metrics.basin({
	basin: "events",
	set: "storage",
	start: sixHoursAgo,
	end: now,
	interval: "hour",
});

// Stream-level: storage for a specific stream
const streamMetrics = await client.metrics.stream({
	basin: "events",
	stream: "user-actions",
	set: "storage",
	start: hourAgo,
	end: now,
	interval: "minute",
});
See the metrics guide for available metric sets and response formats.