mastra-ai/mastra · error · MastraError
OBSERVABILITY_STORAGE_GET_METRIC_AGGREGATE_NOT_IMPLEMENTED
OBSERVABILITY_STORAGE_GET_METRIC_AGGREGATE_NOT_IMPLEMENTED
Error message
This storage provider does not support metric aggregation
What it means
MastraError OBSERVABILITY_STORAGE_GET_METRIC_AGGREGATE_NOT_IMPLEMENTED is thrown by the default getMetricAggregate() implementation in the observability storage base class (packages/core/src/storage/domains/observability/base.ts:450). It indicates the active storage adapter does not implement metric aggregation (e.g. sum/count/avg over metric observations). The base class throws for every unimplemented method so adapters only need to override what they support.
Source
Thrown at packages/core/src/storage/domains/observability/base.ts:450
throw new MastraError({
id: 'OBSERVABILITY_STORAGE_BATCH_CREATE_METRICS_NOT_IMPLEMENTED',
domain: ErrorDomain.MASTRA_OBSERVABILITY,
category: ErrorCategory.SYSTEM,
text: 'This storage provider does not support batch creating metrics',
});
}
async listMetrics(_args: ListMetricsArgs): Promise<ListMetricsResponse> {
throw new MastraError({
id: 'OBSERVABILITY_STORAGE_LIST_METRICS_NOT_IMPLEMENTED',
domain: ErrorDomain.MASTRA_OBSERVABILITY,
category: ErrorCategory.SYSTEM,
text: 'This storage provider does not support listing metrics',
});
}
async getMetricAggregate(_args: GetMetricAggregateArgs): Promise<GetMetricAggregateResponse> {
throw new MastraError({
id: 'OBSERVABILITY_STORAGE_GET_METRIC_AGGREGATE_NOT_IMPLEMENTED',
domain: ErrorDomain.MASTRA_OBSERVABILITY,
category: ErrorCategory.SYSTEM,
text: 'This storage provider does not support metric aggregation',
});
}
async getMetricBreakdown(_args: GetMetricBreakdownArgs): Promise<GetMetricBreakdownResponse> {
throw new MastraError({
id: 'OBSERVABILITY_STORAGE_GET_METRIC_BREAKDOWN_NOT_IMPLEMENTED',
domain: ErrorDomain.MASTRA_OBSERVABILITY,
category: ErrorCategory.SYSTEM,
text: 'This storage provider does not support metric breakdown',
});
}
async getMetricTimeSeries(_args: GetMetricTimeSeriesArgs): Promise<GetMetricTimeSeriesResponse> {
throw new MastraError({View on GitHub (pinned to 75dd419e61)
Solutions
- Use a storage adapter that implements getMetricAggregate or upgrade the existing adapter package to a version that does.
- Change storage configuration to a metrics-capable provider (e.g. PostgreSQL) if you need metric aggregates.
- If you own a custom adapter, implement getMetricAggregate returning the computed GetMetricAggregateResponse for your backend.
- Guard the call site: detect missing support (instance does not override getMetricAggregate) and return null/empty instead of throwing.
Example fix
// before
await storage.getMetricAggregate({ metricName: 'agent_tokens' }); // throws
// after
const aggregate = storage.getMetricAggregate !== MastraStorage.prototype.getMetricAggregate
? await storage.getMetricAggregate({ metricName: 'agent_tokens' })
: null; Defensive patterns
Strategy: fallback
Validate before calling
import { MastraStorage } from '@mastra/core/storage';
function supportsMetricAggregate(storage: unknown): boolean {
return (
storage instanceof MastraStorage &&
(storage as MastraStorage).getMetricAggregate !== MastraStorage.prototype.getMetricAggregate
);
}
if (!supportsMetricAggregate(storage)) {
console.warn('Aggregate metric queries unsupported by this storage adapter');
} Type guard
function supportsMetricAggregate(s: unknown): s is MastraStorage & { getMetricAggregate: (a: GetMetricAggregateArgs) => Promise<GetMetricAggregateResponse> } {
return s instanceof MastraStorage && s.getMetricAggregate !== MastraStorage.prototype.getMetricAggregate;
} Try / catch
import { MastraError } from '@mastra/core/error';
try {
const agg = await storage.getMetricAggregate(args);
} catch (err) {
if (err instanceof MastraError && err.id === 'OBSERVABILITY_STORAGE_GET_METRIC_AGGREGATE_NOT_IMPLEMENTED') {
const agg = null; // render 'aggregates unavailable' instead of failing
} else {
throw err;
}
} Prevention
- Verify the provider implements metric aggregation (sum/count/avg) before building dashboards on it.
- Pin matching versions of @mastra/core and the storage adapter to avoid capability skew.
- Override getMetricAggregate in custom adapters, or intentionally return an empty response.
- Add a startup capability probe that logs which observability methods the adapter overrides.
- Keep an integration test covering getMetricAggregate against your storage backend.
When it happens
Trigger: Calling getMetricAggregate(args) on a storage adapter that has not overridden it — typically through the metrics API/Studio metric summary view while connected to a provider lacking metrics aggregation support.
Common situations: Requesting an aggregate (count/sum/avg) for a metric in Studio against an adapter that only stores spans; custom MastraStorage subclass missing getMetricAggregate; mixing a newer core version that queries aggregates with an older storage package.
Related errors
- OBSERVABILITY_STORAGE_BATCH_CREATE_METRICS_NOT_IMPLEMENTED
- OBSERVABILITY_STORAGE_LIST_METRICS_NOT_IMPLEMENTED
- OBSERVABILITY_STORAGE_GET_METRIC_BREAKDOWN_NOT_IMPLEMENTED
- OBSERVABILITY_STORAGE_GET_METRIC_TIME_SERIES_NOT_IMPLEMENTED
- OBSERVABILITY_STORAGE_GET_METRIC_PERCENTILES_NOT_IMPLEMENTED
AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30).
Data as JSON: /api/errors/eccb48f32ffd2fb4.
Report an issue: GitHub.