You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Roadmap Phase 4 → Analytics & Monitoring → #74 Create custom metrics and KPIs has no tracking issue. It is the remaining gap in a section whose other three items have shipped: #339 (analytics dashboard, roadmap #71), #340 (real-time performance monitoring, #72) and #341 (configurable alerting, #73).
Those three cover fixed, developer-defined metrics. #74 is about letting an operator define a metric without a code change — pick a source, an aggregation, a window and a dimension, name it, and have it appear in the dashboard and be alertable.
Background
What exists today:
packages/api/rest/src/services/monitoring/ — transaction-monitoring.service.ts, monitoring-alert.service.ts, alert-evaluator.ts, transaction-rule-engine.ts, and a channel dispatcher with webhook and notification channels
packages/api/rest/src/routes/monitoring/ — transactions.ts and alerts.ts
alert-evaluator.ts and transaction-rule-engine.ts already evaluate conditions over transaction data, which is the closest existing analogue and the natural thing to generalize rather than duplicate.
What is missing is the definition layer: every metric is currently hardcoded, so adding one means editing a service, opening a PR and redeploying.
Requirements
Metric definition model
A metric_definitions table and a typed model: id, userId/orgId, name, description, source, aggregation, window, dimensions, filters, unit, enabled
Sources drawn from what the DevKit already records: transactions, wallet events, DeFi positions, oracle prices, automation executions, API request logs
Description
Roadmap Phase 4 → Analytics & Monitoring → #74 Create custom metrics and KPIs has no tracking issue. It is the remaining gap in a section whose other three items have shipped: #339 (analytics dashboard, roadmap #71), #340 (real-time performance monitoring, #72) and #341 (configurable alerting, #73).
Those three cover fixed, developer-defined metrics. #74 is about letting an operator define a metric without a code change — pick a source, an aggregation, a window and a dimension, name it, and have it appear in the dashboard and be alertable.
Background
What exists today:
packages/api/rest/src/services/monitoring/—transaction-monitoring.service.ts,monitoring-alert.service.ts,alert-evaluator.ts,transaction-rule-engine.ts, and a channel dispatcher with webhook and notification channelspackages/api/rest/src/routes/monitoring/—transactions.tsandalerts.tsalert-evaluator.tsandtransaction-rule-engine.tsalready evaluate conditions over transaction data, which is the closest existing analogue and the natural thing to generalize rather than duplicate.What is missing is the definition layer: every metric is currently hardcoded, so adding one means editing a service, opening a PR and redeploying.
Requirements
Metric definition model
metric_definitionstable and a typed model:id,userId/orgId,name,description,source,aggregation,window,dimensions,filters,unit,enabledcount,sum,avg,min,max,p50/p95/p99,rate,distinct_count5m,1h,24h,7d,30d) and calendar windows (day/week/month to date)failed_tx / total_tx). Detect and reject cyclesEvaluation
MetricsServicethat compiles a definition into a parameterized Supabase query — never string-concatenated SQL30dmetric must not be recomputed per requestKPI targets
API
POST/GET/PATCH/DELETE /api/v1/metrics/definitions— full CRUD, scoped to the ownerGET /api/v1/metrics/:id/value— current value, optional dimension filtersGET /api/v1/metrics/:id/series— time series for charting, with explicit bucket sizePOST /api/v1/metrics/preview— evaluate an unsaved definition, so the UI can validate before savingIntegration
monitoring-alert.service.ts, reusing the existing channel dispatcher rather than adding a parallel oneGuardrails
Acceptance Criteria
previewevaluates without persistingReferences
packages/api/rest/src/services/monitoring/alert-evaluator.ts,transaction-rule-engine.ts