Custom Alerting on Business Metrics
Technical alerts on CPU and latency matter, but business rarely understands their impact. "Completed orders dropped 40% in last 15 minutes" is clear to everyone — developers and CEOs alike. Business metric alerts bridge the gap between technical monitoring and business impact.
Business Metrics for Alerting
Metrics depend on product type, but typical categories:
E-commerce:
- Completed orders per hour (sharp decline)
- Conversion from cart to payment (if < baseline X%)
- Revenue per rolling hour
- Payment errors (absolute count)
SaaS:
- New user registrations (zero in last N hours)
- Active online users (unexpected drop)
- API requests from key customers (anomalous rise/fall)
Content projects:
- Page views (sharp drop = SEO or CDN issue)
- Bounce rate (sharp rise)
- Forms submitted (zero in N hours)
Implementation via Prometheus
Business events in application code:
from prometheus_client import Counter, Histogram
# Initialize metrics
orders_completed = Counter(
'orders_completed_total',
'Total completed orders',
['payment_method', 'product_category']
)
order_value = Histogram(
'order_value_rub',
'Order value in rubles',
buckets=[100, 500, 1000, 2500, 5000, 10000, 25000, 50000]
)
payment_errors = Counter(
'payment_errors_total',
'Payment processing errors',
['error_code', 'payment_provider']
)
# In order completion code
async def complete_order(order_data: dict):
try:
result = await payment_gateway.charge(order_data)
orders_completed.labels(
payment_method=order_data['payment_method'],
product_category=order_data['category']
).inc()
order_value.observe(order_data['amount'])
Alert Rules in Alertmanager
groups:
- name: business_alerts
rules:
# E-commerce: orders dropped
- alert: OrdersDropped
expr: rate(orders_completed_total[15m]) < (rate(orders_completed_total[15m] offset 60m) * 0.6)
for: 5m
annotations:
summary: "Orders dropped 40% in last 15 min"
severity: "critical"
slack: "#alerts-ecommerce"
# SaaS: no signups
- alert: NoSignups
expr: rate(user_signups_total[1h]) == 0
for: 30m
annotations:
summary: "Zero signups in last 30 minutes"
severity: "warning"
# Payment processing errors spike
- alert: PaymentErrorsSpike
expr: rate(payment_errors_total[5m]) > 0.5 # >50% error rate
for: 2m
annotations:
summary: "Payment errors > 50%"
severity: "critical"
Slack Notifications
import requests
def send_alert_to_slack(alert_name, severity, details):
color = {'critical': '#FF0000', 'warning': '#FFA500'}.get(severity)
message = {
'attachments': [{
'color': color,
'title': alert_name,
'text': details,
'footer': 'Business Metrics Alert'
}]
}
requests.post(SLACK_WEBHOOK, json=message)
Delivery Time
Setting up business metric collection, alerts, and notifications — 2–3 business days.







