You’ve been there before. You open the weekly performance dashboard to see that a critical Key Performance Indicator (KPI), like user sign-ups or customer retention, has taken a nosedive. The problem is, the drop happened three days ago. Now, you’re playing catch-up, trying to diagnose a problem that’s already impacted your goals.
Traditional dashboards are useful for historical review, but they are fundamentally reactive. They require you to manually pull information, leaving a dangerous lag between an event and your awareness of it.
What if your metrics could talk? What if, instead of you checking on them, they actively notified you the moment they needed attention? This is the power of proactive alerting, and it transforms your KPIs from static charts into dynamic, automated services that drive immediate action. With an API-first approach like KPIs.do, you can set up intelligent alert workflows that pipe crucial insights directly into your team's daily tools, like Slack.
Relying solely on dashboards for performance monitoring creates several challenges:
The solution is to shift your mindset from pulling data to having data pushed to you. By automating alerts, you build an intelligent monitoring system that works for you 24/7.
This is where the concept of Metrics as Code comes in. Instead of building a visual chart, you define a KPI's logic, data sources, and thresholds programmatically. At KPIs.do, our agentic workflow platform takes this definition and turns it into an autonomous service. Our agents continuously fetch data, perform calculations, analyze trends, and—most importantly—trigger actions when predefined conditions are met.
Let's walk through how you can set up an automated alert for a "Monthly Active Users" (MAU) KPI and send notifications directly to a Slack channel.
First, you define your KPI using the KPIs.do API. You specify its name, how to calculate its value (e.g., a SQL query against your production database), and what your targets are.
import { KPIs } from '@do/sdk';
// Define the logic, source, and targets for a new KPI
const mauDefinition = {
id: 'monthly-active-users',
name: 'Monthly Active Users',
description: 'Tracks the number of unique users who log in within a 30-day period.',
dataSource: {
type: 'sql',
connectionId: 'prod-db-connection',
query: 'SELECT COUNT(DISTINCT user_id) FROM user_logins WHERE login_timestamp >= NOW() - INTERVAL \'30 days\';',
},
targets: {
goal: 5000,
thresholds: {
atRisk: 4900, // Becomes 'at-risk' if it drops below this
offTrack: 4750, // Becomes 'off-track' if it drops below this
}
},
// ... alert configuration comes next
};
await KPIs.define(mauDefinition);
With this definition, the KPIs.do platform now knows how to independently calculate your MAU.
Next, you'll extend the KPI definition to include alerting rules. You can trigger alerts based on status changes (on-track, at-risk) or negative trends. For this, we'll use a webhook. Webhooks are a simple way for applications to send automated messages to other applications.
First, you'll need to generate an "Incoming Webhook" URL from Slack. You can do this in just a few clicks within your Slack workspace settings.
Once you have your Slack webhook URL, add the alerts configuration to your KPI definition.
// Continuing the mauDefinition object from above...
const mauDefinition = {
// ... all the properties from Step 1
alerts: [
{
// Trigger this alert when the status is no longer 'on-track'
trigger: 'on_status_change',
condition: {
status: ['at-risk', 'off-track']
},
action: {
type: 'webhook',
url: 'https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX',
payload: {
text: `🚨 *KPI Alert:* ${kpi.name}\n> Value: ${kpi.currentValue} | Target: ${kpi.target}\n> Status: *${kpi.status}* | Trend: *${kpi.trend}*`
}
}
}
]
};
await KPIs.define(mauDefinition);
Now, you've created a fully automated workflow. The platform's agents will:
The moment your MAU metric dips below 4900, your designated Slack channel will receive a message like this:
🚨 KPI Alert: Monthly Active Users
Value: 4850 | Target: 5000
Status: at-risk | Trend: decreasing
Your team is now instantly aware of the issue and can begin investigating immediately, closing the gap between insight and action from days to seconds.
Slack is just the beginning. Because KPIs.do uses generic webhooks, you can connect your metrics to virtually any other service or platform with an API:
This transforms your KPIs from passive numbers on a screen into active participants in your operational workflows.
It's time to graduate from reactive dashboard-checking. By defining your metrics as code and connecting them to automated alert systems, you build a truly data-driven organization that is responsive, efficient, and always ready for action.
Ready to turn your key metrics into actionable services? Explore the KPIs.do API and build your first automated monitoring workflow today.