Monitoring
kpis
Key Performance Indicators tracking and management
kpis
Key Performance Indicator (KPI) tracking, calculation, and visualization with goal setting, alerting, and historical analysis.
Overview
The KPIs primitive provides a framework for defining, tracking, and analyzing business metrics with automatic calculation, goal tracking, and trend analysis.
Parent Primitive: analytics - Analytics and metrics platform
SDK Object Mapping
This primitive maps to the send and decide SDK objects:
import { send, decide, kpis } from 'sdk.do'
// Define KPI
const mrr = await kpis.define({
name: 'Monthly Recurring Revenue',
key: 'mrr',
calculation: async () => {
const subscriptions = await db.list('subscriptions', {
where: { status: 'active' },
})
return subscriptions.reduce((sum, sub) => sum + sub.amount, 0)
},
goal: 100000,
})
// Track KPI event
await send('kpi.updated', {
key: 'mrr',
value: await kpis.value('mrr'),
})
// Use in experiments
await decide.track({
experiment: 'pricing-test',
metric: 'mrr',
value: await kpis.value('mrr'),
})Quick Example
import { kpis } from 'sdk.do'
// Define KPI
const mrr = await kpis.define({
name: 'Monthly Recurring Revenue',
key: 'mrr',
unit: 'usd',
calculation: async () => {
const subscriptions = await db.list('subscriptions', {
where: { status: 'active' },
})
return subscriptions.reduce((sum, sub) => sum + sub.amount, 0)
},
goal: 100000,
frequency: 'daily',
})
// Get current value
const current = await kpis.value('mrr')
// Get trend
const trend = await kpis.trend('mrr', {
timeRange: 'last-90-days',
interval: 'day',
})
// Set alert
await kpis.alert('mrr', {
condition: 'below',
threshold: 80000,
notify: ['[email protected]'],
})Core Capabilities
- KPI Definition - Define metrics with calculations and goals
- Automatic Calculation - Scheduled metric updates
- Goal Tracking - Set and monitor goals with progress
- Trend Analysis - Historical data and trend visualization
- Alerts - Notifications when KPIs hit thresholds
Access Methods
SDK
TypeScript/JavaScript library for KPI management
await kpis.define({ name: 'MRR', key: 'mrr', calculation: async () => {...} })CLI
Command-line tool for KPI operations
do kpi value mrr --time-range last-30-daysAPI
REST/RPC endpoints for KPI tracking
curl -X GET https://api.do/v1/kpis/mrr/valueMCP
Model Context Protocol for AI-driven KPI analysis
Get the current value of MRR KPI for the last 30 daysRelated Primitives
Parent Primitive
- analytics - Analytics and metrics platform
Sibling Primitives
- performance - Performance monitoring
- trace - Distributed tracing
- experiments - A/B testing