Mastra 平台推出 Metrics API
Mastra 发布平台 Metrics API,开发者可通过 Mastra Client SDK、Mastra CLI 或可观测性端点查询生产项目的 token 用量、模型成本、延迟和错误率。该 API 支持总量、分组、时间序列和百分位数据,并可结合时间范围与状态过滤条件,用于生成自定义报告、看板、下游数据推送和告警。Mastra 表示,指标会跨所有运行聚合,而 trace 只展示单次运行的情况。
该 API 让团队以编程方式查询和聚合生产指标,可用于自定义看板、告警,以及让智能体动态构建查询。
You can now query token usage, model cost, latency, and error rates with Mastra platform's Metrics API. Use the Mastra Client SDK, Mastra CLI, or observability endpoints to get totals, breakdowns, time series, and percentile data from production Mastra projects.
Traces show what happened in a single run, while metrics aggregate across every run. This lets you see which model, conversation, or tool calls cost the most, run the slowest, or fail most often. You can combine query types with time ranges and status filters to surface important insights to share with your team.
Your browser does not support the video tag.
We launched metrics earlier this year, letting you view model costs, latency, and error counts in Mastra platform and Studio. Today, using the Metrics API, you can construct your own queries to generate custom reports, build dashboards, send data to downstream services, or post alerts to connected chat platforms when model costs or error rates rise.
You can combine the Metrics API with code mode to build agents capable of constructing their own queries on the fly to answer questions, summarize insights, or generate PDFs for team members and stakeholders.