Alert rules ยท Contact points ยท Routing ยท Alert design strategy
| Time | Segment | Activity |
|---|---|---|
| 0โ10 min | Recap | L15 dashboards โ what are you watching and why? |
| 10โ25 min | Why Alerts Matter | The "sleeping in front of a dashboard" problem |
| 25โ40 min | Grafana Alert Architecture | Rules, contact points, notification policies, state machine |
| 40โ60 min | Lab Part 1 | Create alert rules from the transaction-risk dashboard |
| 60โ70 min | Lab Part 2 | Configure email / Slack contact point + routing |
| 70โ80 min | Alert Design Framework | Thresholds, routing, escalation, fatigue |
| 80โ88 min | Case Studies | Zepto & HDFC Securities production alerting |
| 88โ90 min | Module 4 Wrap-Up | Course arc + Final Project preview |
A dashboard is only useful if someone is looking at it. In a 24-hour streaming system, no one watches 24 hours a day. Alerts let the data come to you โ instead of you going to the data.
Without alerts: 10:47 PM Flagged transaction rate crosses the operating threshold 10:47 PM Nobody sees it 11:30 PM Risk manager checks Grafana manually โ too late With alerts: 10:47 PM Grafana alert fires โ Slack message in #fraud-ops 10:48 PM Manager opens the review queue and assigns an analyst
| Tool | Purpose | Acts On |
|---|---|---|
| Logging | Record everything that happened | Engineers debugging after an event |
| Monitoring | Show current state continuously | Teams watching dashboards |
| Alerting | Notify when action is needed | Decision-makers who need to respond |
Key principle: The goal of an alert is to trigger a human action. If an alert fires and nobody knows what to do, the alert is not useful โ it is noise. Every alert rule should have a corresponding runbook: who gets notified and what they do.
Without a "For" duration, a single bad data point triggers an alert. With For: 2m, the condition must be true for 2 continuous minutes before the alert fires.
Without "For": Check 1: Fraud rate = 3.8% โ FIRES immediately Check 2: Fraud rate = 3.4% โ Resolves โ short-lived spike With For: 2m: Check 1: Fraud rate = 3.8% โ enters PENDING state 2 min later: still above 3.5% โ FIRES โ sustained risk, worth investigating.
Navigate: Left sidebar โ Alerting (bell icon) โ Alert Rules โ New alert rule
Name: Transaction Risk โ High Fraud Rate | Data source: MySQL
Query: reuse the Lecture 14 fraud-rate SQL query against the transactions table
Condition: IS ABOVE 3.5% for the classroom dataset | Evaluate every: 1m | For: 2m
Labels: severity=warning, team=fraud-ops
Annotations: Summary: "Flagged transaction rate exceeds threshold" | Description: "Current rate is {{ $value }}%. Open the review queue and assign an analyst."
is_fraud = 'true' and amount > 50000.severity=critical, team=fraud-ops.SELECT COUNT(*) AS value FROM transactions WHERE is_fraud = 'true' AND amount > 50000;
Threshold design discussion: Is โน50,000 appropriate for every customer and merchant? An absolute threshold is easy to explain, but a customer-relative threshold can be more accurate. The correct choice depends on false-positive cost, customer history, and response capacity.
Requires SMTP configuration in Docker. Add environment variables to the Grafana run command:
-e GF_SMTP_ENABLED=true -e GF_SMTP_HOST=smtp.gmail.com:587 -e GF_SMTP_USER=your@gmail.com -e GF_SMTP_PASSWORD=your-app-password
Then: Alerting โ Contact points โ New โ Type: Email โ Add your address โ Test
api.slack.com/apps โ Create New App โ Incoming Webhooks โ Activate#grafana-alertshttps://hooks.slack.com/services/T.../B.../...Alerting โ Notification policies โ Edit root policy โ Add matchers:
severity = critical โ Slackseverity = warning โ EmailFIRING: Transaction Risk โ High Fraud Rate Severity: warning | Team: fraud-ops Flagged transaction rate exceeds threshold Current value: 3.8% Starts at: 11:47:00 Dashboard: http://localhost:3000/d/...
| Notification Cost | Example | Threshold Approach |
|---|---|---|
| Low (Slack message, easy to dismiss) | Single high-value flagged case | Sensitive threshold may be acceptable |
| Medium (email + calendar) | Fraud rate above operating threshold | Threshold needs care, use "For: 2m" |
| High (PagerDuty, on-call woken up) | System outage, fraud spike | Very precise threshold, long "For" duration |
Alert fatigue = when so many alerts fire that operators start ignoring them โ including the ones that matter.
For: 2m or longer on non-critical rules โ filters out single-tick blipsZepto operates ~350 dark stores. Their alerting rules:
order_acceptance_rate < 90% for 3 minutes โ Slack to store ops manageravg_delivery_time > 35 min for 5 minutes โ Escalation to city headinventory_stockout_count > 20 SKUs โ Automated reorder + alertDiscussion: Why is the "For" duration 3 minutes for order acceptance but 5 minutes for delivery time? What is different about the business consequence of each?
price_feed_latency > 500ms โ PagerDuty (on-call engineer, 24/7)order_rejection_rate > 2% โ Critical Slack + SMS to CTOactive_users_drop > 30% in 5 min โ Infrastructure alert (possible outage)Discussion: The order rejection rate alert goes to the CTO, not an engineer. Why? What does this tell you about how alerting functions as a business communication tool, not just a technical one?
| L14: Grafana Basics | L15: Dashboard Build | L16: Alerts | |
|---|---|---|---|
| Concept | Data sources, panels, dashboards | Dashboard design + live multi-panel build | Alert rules, contact points, routing |
| Built | Transaction-risk dashboard | Four-panel fraud-operations dashboard | Transaction alert rules with Slack/email routing |
| Business skill | Understand the visual layer | Design a dashboard around a business question | Design an alerting strategy that creates action |
Module 1 (L1-L5): UNDERSTAND โ What is streaming? How does Kafka work? Module 2 (L6-L10): BUILD โ Producer, consumer, persistence, alert routing Module 3 (L11-L13): SCALE โ Windowing, Spark, Flink โ enterprise patterns Module 4 (L14-L16): VISUALISE โ Grafana dashboards + alert routing Module 5 (L17-L18): DECIDE โ Multi-source pricing, explainability, governance Module 6 (L19-L20): PRESENT โ Final project and architecture review
The alert rules above evaluate data already stored in MySQL. The extension reconnects every course component so students can watch the system operate: the producer publishes, two Kafka consumers persist transactions and alert events, and Grafana refreshes from both tables every five seconds.
Open the guided extension: Kafka to MySQL to a Real-Time Fraud Dashboard. It includes the required files, terminal sequence, reset commands, live SQL queries, dashboard layout, and management discussion.
L17: Build an end-to-end Uber-style surge pricing simulation from demand, driver supply, weather, traffic, and events.
L18: Compare pricing policies, explain decisions, and audit guardrails.
Start thinking: When should an automated decision be capped, suspended, or reviewed by a human?