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.
// Account-level: active basins over the last 30 days
const accountMetrics = await s2.metrics.account({
	set: "active-basins",
	start: new Date(Date.now() - 30 * 24 * 3600 * 1000),
	end: new Date(),
});

// Basin-level: storage usage with hourly resolution
const basinMetrics = await s2.metrics.basin({
	basin: "events",
	set: "storage",
	start: new Date(Date.now() - 6 * 3600 * 1000),
	end: new Date(),
	interval: "hour",
});

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