Module 4 ยท Lecture 15

Building Live Streaming Dashboards in Grafana

Multi-panel build ยท Variables ยท Assignment 3 guidance

โฑ 90 minutes ๐Ÿ“ Prerequisites: Lecture 14 (Grafana connected to Atlas) ๐Ÿ”ง Full hands-on build session

Contents

  1. Learning Objectives
  2. Session Timeline
  3. Dashboard Design Principles
  4. Lab Part 1 โ€” Stock Monitor (4 panels)
  5. Lab Part 2 โ€” Variables & Interactivity
  6. Transactions Dashboard (quick build)
  7. Design Review Checklist
  8. Assignment 3 Guidance
  9. Key Takeaways

Learning Objectives

Session Timeline

TimeSegmentActivity
0โ€“10 minSetup CheckVerify Grafana running, producer running, data flowing
10โ€“20 minDesign PrinciplesWhat makes a dashboard useful vs pretty
20โ€“50 minLab Part 1Build stock monitor dashboard (4 panels)
50โ€“65 minLab Part 2Add variable dropdown + alert summary panel
65โ€“75 minTransactions DashboardQuick build from L10 transactions-topic data
75โ€“85 minDesign ReviewStudent dashboards โ€” what works, what doesn't
85โ€“90 minA3 GuidanceAssignment 3 requirements and tips

Section 1: Dashboard Design Principles

The most common mistake: Building a dashboard that answers "What data do I have?" โ€” instead of "What decision does this dashboard support?"

The Four Rules

  1. One question per panel, one job per dashboard. If a panel needs a paragraph to explain it, split it.
  2. Most important information top-left. Humans read dashboards like text โ€” put your critical KPI there.
  3. Use colour to mean something, not for decoration. Green = normal, Amber = watch, Red = act. If everything is red, nothing is urgent.
  4. Refresh rate matches decision speed. Risk monitoring = 10s. Operations = 1 min. Executive = 5 min or manual.

Section 2: Lab Part 1 โ€” Stock Monitor Dashboard

Target Layout

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  Stock Monitor  [Symbol: INFY โ–ผ]  [Last 30 min โ–ผ]      โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚  Current     โ”‚  Open        โ”‚                          โ”‚
โ”‚  Price       โ”‚  Alerts      โ”‚  INFY Price (30 min)     โ”‚
โ”‚  (Stat)      โ”‚  (Stat)      โ”‚  (Time Series)           โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค                          โ”‚
โ”‚  Price Change from          โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚  Last Batch (%)             โ”‚  Alert Log (Table)       โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค  Latest 5 alerts         โ”‚
โ”‚  Min / Max Bar Gauge        โ”‚                          โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Panel 1 โ€” Current Price (Stat)

Current Price
Business question: "What is INFY trading at right now?"

Query: stock_prices collection, match symbol=INFY, sort by _saved_at desc, limit 1, project price

{
  "collection": "stock_prices",
  "aggregate": [
    { "$match": { "symbol": "INFY" } },
    { "$sort": { "_saved_at": -1 } },
    { "$limit": 1 },
    { "$project": { "_id": 0, "price": 1 } }
  ]
}

Settings: Visualisation = Stat | Unit = โ‚น | Thresholds = none (price level is neutral)

Panel 2 โ€” Open Alerts Count (Stat)

Open Alerts
Business question: "How many unreviewed alerts are in the queue?"
{
  "collection": "stock_alerts",
  "aggregate": [
    { "$match": { "status": "open" } },
    { "$count": "value" }
  ]
}

Thresholds: 0โ€“2 = green | 3โ€“5 = amber | 6+ = red

Discussion: Ask students โ€” "What threshold makes sense for your Assignment 3 dataset?" There is no universal answer; the business context determines urgency.

Panel 3 โ€” Price History Time Series

INFY Price โ€” Last 30 Minutes
Business question: "What has INFY's price done recently?"
{
  "collection": "stock_prices",
  "aggregate": [
    { "$match": { "symbol": "INFY", "_saved_at": { "$gte": "$__from" } } },
    { "$sort": { "_saved_at": 1 } },
    { "$project": { "_id": 0, "time": "$_saved_at", "price": 1 } }
  ]
}

Settings: Line width = 2 | Fill opacity = 10 | Unit = โ‚น | Tooltip = All

Panel 4 โ€” Alert Log Table

Recent Alerts
Business question: "What were the last 5 alerts and why did they fire?"
{
  "collection": "stock_alerts",
  "aggregate": [
    { "$sort": { "alert_at": -1 } },
    { "$limit": 5 },
    { "$project": {
        "_id": 0, "symbol": 1,
        "mean_price": "$stats.mean",
        "min": "$stats.min", "max": "$stats.max",
        "reason": { "$arrayElemAt": ["$alert_reasons", 0] },
        "time": "$alert_at"
    }}
  ]
}

Settings: Visualisation = Table | Sort by Time descending

Section 3: Lab Part 2 โ€” Variables & Interactivity

Adding a Symbol Dropdown

Variables make dashboards reusable โ€” one dashboard works for INFY and TCS instead of building two.

  1. Dashboard settings (gear icon) โ†’ Variables โ†’ New variable
  2. Name: symbol | Type: Custom | Values: INFY, TCS | Default: INFY
  3. Save. Now replace "symbol": "INFY" with "symbol": "$symbol" in all panel queries.

The dropdown now filters all panels simultaneously โ€” one click switches the entire dashboard from INFY to TCS.

Saving & Sharing

  1. Save icon โ†’ name: "SDA โ€” Stock Monitor"
  2. Share โ†’ Snapshot โ†’ generates a public link (no Grafana login required to view)

Section 4: Transactions Dashboard

Quick build using the transactions-topic data from Lecture 10. Use as a second pattern reference for Assignment 3.

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  Transaction Monitor  [City: All โ–ผ]  [1h โ–ผ] โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ Total Txns  โ”‚  Transaction Volume             โ”‚
โ”‚ Last Hour   โ”‚  Time Series โ€” count per min   โ”‚
โ”‚  (Stat)     โ”‚                                โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚  Avg Amount per Minute  โ”‚  Top Cities        โ”‚
โ”‚  (Time Series)          โ”‚  (Bar Chart)       โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Queries follow the same pattern as stock panels โ€” change collection to transactions and field names to match your L10 schema (amount, city, timestamp).

Section 5: Design Review Checklist

For each dashboard, evaluate:

QuestionWhat to Look For
Does it answer a clear business question?"Who is the user? What decision are they making?" โ€” one sentence
Is colour usage consistent?Red = alert/bad, Green = normal. No decorative red on neutral data.
Is the refresh rate appropriate?30s is fine for demos; 5s for live risk monitoring
Are axes labelled with units?Always: โ‚น, count, %, minutes โ€” never raw numbers without context
Is the time range visible?Users should always know what window of data they are looking at

Assignment 3 Guidance

Due: 1 October | 15 marks

Create a dashboard for the analysis of your consumed data (the domain from A1, streamed in A2).

RequirementDetail
Minimum 4 panelsAt least 1 time series, 1 stat/KPI, 1 table
Real dataConnected to your Kafka consumer data (MongoDB or InfluxDB)
1 variable/filterMakes the dashboard interactive
Colour thresholdsReflect actual business logic โ€” not default colours
Explanation200-word write-up: what business question each panel answers

Submission: Export dashboard JSON (Dashboard โ†’ Share โ†’ Export JSON) + screenshots. Upload to GitHub with tag [A3][SDA-1], [A3][SDA-2], or [A3][SDA-G].

Quality signal: Write this before building: "As a [role] at [company type], I want to see [metric] so that I can [decision]." Students who write this user story first consistently produce better dashboards.

Key Takeaways

โœ“ Key Takeaways โ€” Lecture 15

  1. Start with the business question, not the chart type โ€” "What decision does this support?"
  2. Most important KPIs top-left; main chart takes the most space
  3. Variables make dashboards reusable โ€” one dashboard for all symbols/cities instead of duplicating
  4. Colour is communication โ€” use thresholds intentionally; miscalibrated thresholds create alert fatigue
  5. Refresh rate = decision speed โ€” match the refresh to how quickly the user needs to act

Preview โ€” Lecture 16: Alerts in Grafana

Configure Grafana alert rules on your dashboards, route notifications to email or Slack, and design an alerting strategy that creates action โ€” not noise.