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 MySQL) πŸ”§ Full hands-on build session

Contents

  1. Learning Objectives
  2. Session Timeline
  3. Dashboard Design Principles
  4. Lab Part 1 β€” Fraud Operations Dashboard
  5. Lab Part 2 β€” Variables & Interactivity
  6. Live Dashboard Mode
  7. Management Interpretation
  8. Design Review Checklist
  9. Assignment 3 Guidance
  10. Key Takeaways

Learning Objectives

Session Timeline

TimeSegmentActivity
0–10 minSetup CheckOpen the Lecture 14 Transaction Risk dashboard
10–20 minDesign PrinciplesWhat makes a dashboard useful vs pretty
20–55 minLab Part 1Extend the transaction dashboard to five panels
55–70 minLab Part 2Add a city variable and update panel queries
70–75 minInterpretationTurn dashboard evidence into a management action
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 β€” Fraud Operations Dashboard

Set the dashboard time range to 1 August–31 August 2025 so the Daily Transaction Volume panel includes the imported historical records.

Target Layout

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Fraud Operations  [City: All β–Ό]                       β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ Flagged Rate      β”‚ Flagged Transaction Value         β”‚
β”‚ (Stat)            β”‚ (Stat)                            β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ Daily Transaction Volume (Time Series)                 β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ Flagged by Merchant       β”‚ Highest-Value Flagged     β”‚
β”‚ (Bar Chart)               β”‚ Transactions (Table)      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Keep the fraud-rate Stat and review-queue Table from Lecture 14. Add the three panels below, then arrange all five into the target layout.

Panel 1 β€” Flagged Transaction Value (Stat)

Flagged Transaction Value
Business question: "How much money is currently associated with flagged transactions?"
SELECT SUM(amount) AS value
FROM transactions
WHERE is_fraud = 'true';

Settings: Visualisation = Stat | Unit = Indian Rupee | Decimals = 0 | Colour = red

Panel 2 β€” Daily Transaction Volume (Time Series)

Daily Transaction Volume
Business question: "How does transaction activity change across the month?"
SELECT
  $__timeGroupAlias(`timestamp`, '1d'),
  COUNT(*) AS value
FROM transactions
WHERE $__timeFilter(`timestamp`)
GROUP BY 1
ORDER BY 1;

Settings: Visualisation = Time Series | Unit = count | Line width = 2 | Fill opacity = 10

Panel 3 β€” Flagged Transactions by Merchant (Bar Chart)

Flagged Transactions by Merchant
Business question: "Which merchants generate the largest review workload?"
SELECT merchant, COUNT(*) AS value
FROM transactions
WHERE is_fraud = 'true'
GROUP BY merchant
ORDER BY value DESC
LIMIT 10;

Settings: Visualisation = Bar Chart | Category = merchant | Value = count | Orientation = horizontal

Panel 4 β€” Fraud Rate (from Lecture 14)

Flagged Transaction Rate
Business question: "What proportion of all transactions needs review?"

Reuse the Lecture 14 Stat query. Keep thresholds at green below 3%, amber from 3%, and red from 5%.

Panel 5 β€” Review Queue (from Lecture 14)

Highest-Value Flagged Transactions
Business question: "Which cases should analysts inspect first?"

Reuse the Lecture 14 Table query, sorted by converted amount descending and limited to 20 rows.

Discussion: A merchant with many flagged transactions is not automatically fraudulent. It may simply have high transaction volume. A manager should request a fraud-rate comparison before blocking the merchant.

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

Adding a City Dropdown

Variables make one dashboard reusable across locations instead of creating a separate dashboard for every city.

  1. Dashboard settings (gear icon) β†’ Variables β†’ New variable
  2. Name: city | Type: Custom | Values: Mumbai, Delhi, Bengaluru, Hyderabad, Chennai, Kolkata, Pune, Ahmedabad
  3. Enable Include All option and set the custom all value to .*.
  4. Add AND city REGEXP '^${city:raw}$' to queries that already have a WHERE clause.
  5. For queries without WHERE, add WHERE city REGEXP '^${city:raw}$' before GROUP BY.

The dropdown now filters all panels simultaneously. Selecting All uses the .* regular expression and keeps every city.

Saving & Sharing

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

Section 4: Live Dashboard Mode

The dashboard above analyses a completed historical dataset. To watch it change while Kafka is running, use the isolated Lecture 16 Extension files and database. One consumer writes every transaction to sda_course_l16.transactions; the other writes flagged events to sda_course_l16.fraud_alerts.

transaction_producer_16.py
          |
          v
  transactions-topic-l16
       |          |
       v          v
consumer_store_  consumer_alerts_
mysql_16.py      mysql_16.py
       |          |
       v          v
transactions     fraud_alerts
       \          /
        v        v
          Grafana
  1. Set the dashboard range to Last 5 minutes.
  2. Set dashboard refresh to 5s.
  3. Use ingested_at for live transaction panels, not the simulated timestamp.
  4. Use detected_at for the live alert queue.
SELECT
  $__timeGroupAlias(ingested_at, '5s'),
  COUNT(*) AS value
FROM transactions
WHERE $__timeFilter(ingested_at)
GROUP BY 1
ORDER BY 1;

Continue with the complete build: Lecture 16 Extension β€” Kafka to MySQL to a Real-Time Fraud Dashboard clubs the producer, both consumers, database tables, live queries, and dashboard configuration into one guided lab.

Section 5: Management Interpretation

Use the completed dashboard to prepare a 60-second fraud-operations briefing:

  1. State the risk: What is the flagged rate and flagged transaction value?
  2. Locate the workload: Which days, merchants, and cities dominate activity?
  3. Avoid overclaiming: Explain why flagged does not mean confirmed fraud.
  4. Recommend action: Name one investigation, control, or threshold change.

Section 6: 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 the course MySQL transaction dataset or another supported datasource
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 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 + Live Extension

Configure Grafana alert rules and routing, then run the optional end-to-end extension to watch Kafka transactions and fraud alerts appear in MySQL and Grafana in real time.