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 on Open Alerts count panel |
| 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 INFY price drops 6% โ alert fires in stock_alerts 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 #risk-alerts 10:48 PM Manager reviews position, takes action
| 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": Tick 1: Rs 1390 โ FIRES immediately (bad tick? spike? genuine drop?) Tick 2: Rs 1410 โ Resolves โ false alarm. Engineers start ignoring alerts. With For: 2m: Tick 1: Rs 1390 โ enters PENDING state 2 min later: still Rs 1385 โ FIRES โ genuine sustained move, worth acting on.
Navigate: Left sidebar โ Alerting (bell icon) โ Alert Rules โ New alert rule
Name: Stock Alerts โ High Open Count | Data source: MongoDB
Query: stock_alerts collection, match status=open, count
Condition: IS ABOVE 5 | Evaluate every: 1m | For: 2m
Labels: severity=warning, team=risk
Annotations: Summary: "Open alert count has exceeded threshold" | Description: "There are {{ $value }} unreviewed stock alerts."
severity=critical, symbol=INFYThreshold design discussion: Should the threshold be absolute (Rs 1,400) or relative (5% from yesterday's close)? Absolute is simpler to configure. Relative is more accurate but requires the query to compute the deviation. The consumer_alerts.py from Lecture 9 already handles relative alerting at the Kafka layer โ Grafana can handle the absolute floor as a safety net.
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: Stock Alerts โ High Open Count Severity: warning | Team: risk Open alert count has exceeded threshold Current value: 7 Starts at: 11:47:00 Dashboard: http://localhost:3000/d/...
| Notification Cost | Example | Threshold Approach |
|---|---|---|
| Low (Slack message, easy to dismiss) | Warning โ 5+ open alerts | Sensitive threshold OK |
| Medium (email + calendar) | Price below floor | 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 | First panel: INFY time series | Stock monitor + transactions dashboards | 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, MongoDB, alert routing Module 3 (L11-L13): SCALE โ Windowing, Spark, Flink โ enterprise patterns Module 4 (L14-L16): VISUALISE โ Grafana dashboards + alert routing Module 5 (L17-L20): PRESENT โ Atlas Charts, final project, real architectures
L17: MongoDB Atlas Charts โ native charting tool, no separate install required.
L18โL20: Final Project โ architecture review, pipeline critique, presentations.
Start thinking: What business problem are you solving? Who is your end user? What alert would notify a manager without watching the screen?