Kapitoly kurzu
1. Obsahová mapa kurzu 2. Notebooky: PySpark vs Pure Python 3. Demo: Tři cesty a Mini Medallion 4. CU Costs a Capacity Metrics 5. SQL trojúhelník 6. Real-Time Intelligence: demo arc 7. Semantic modely, DAX a optimalizace 8. Security a administrace Fabricu 9. Zkouška DP-600: tipy
Runbooky — medallion
10. Mini Medallion ČHMÚ 11. Mini Medallion NYC Taxi 12. NYC Taxi třemi cestami 13. Mini Medallion OpenAQ 14. Big Medallion OpenAQ (2 roky)
Runbooky — RTI
15. RTI Library: architektura 16. A: Bicycles 60s 17. B: ČHMÚ HTTP polling 18. C: NDIC dopravní detektory 19. D: Camera ALPR simulátor 20. E: PID GTFS-RT 21. F: Activator alerty 22. KQL cheat sheet
🏠 Rozcestník kurzu
DP-600 · Runbook

Runbook F: Activator alerty

Detect → decide → act: tři alert rules nad streamy B a D, Teams a e-mail
📡 Runbook · Real-Time Intelligence

Cíle kapitoly

  • Vytvořit Activator artefakt a napojit ho na KQL stream
  • Definovat objekty, triggery a akce pro tři alert rules (PM10, speeder, watchlist)
  • Nastavit rate limit per objekt a vyhnout se spamu alertů
  • Přenést pattern detect → decide → act na vlastní use case
21.1

Úvod

Pattern: bolt-on k existujícímu KQL streamu · Auth: Teams/email permission· Risk: low Fabric capacity: F2 OK Depends on: Runbook B (CHMU) and/or D (ALPR) — Activator potřebuje stream s daty

21.2

Cíl

Microsoft Fabric Activator (driv "Data Activator", projekt code-name Reflex) sleduje data v KQL DB / Eventstream / PBI a triggeruje akce: Teams notifikace, email, HTTP webhook, Power Automate flow.

V tomto runbooku postavíme 3 alert rules napříč ostatními runbooky:

  1. B-PM10: ČHMÚ překročení EU limitu PM10 v jakékoli stanici → Teams message do #environment-alerts
  2. D-Severe-Speeder: ALPR detekce vozidla s rychlostí limit + 30 km/h → email s plate číslem
  3. D-Watchlist-Match: ALPR detekce license plate z hardcoded watchlist → Teams + email

Pedagogická hodnota:

  • Closure RTI loopu — detect → decide → act v rámci Fabric platformy
  • No-code rule editor (klient může spravovat sám, bez DEV teamu)
  • Integration story s Microsoft 365 ekosystémem

Reuse mimo kurz:

  • Klientské scénáře — předal Activator setup tvůrcům business pravidel, dev tým drží data layer
  • Compliance a operational alerting — environmentální monitoring, fleet tracking, anti-fraud
21.3

Architektura

SCHÉMA
┌─────────────────────────────────┐       ┌─────────────────────────────────┐
│ KQL DB / Eventstream            │       │ PBI Semantic Model              │
│  • b_chmi_clean (PM10 over EU)  │       │  • measure value tracking       │
│  • d_alpr_clean (speeders)      │       │                                 │
└──────────────┬──────────────────┘       └──────────────┬──────────────────┘
               │                                          │
               │ Activator object subscribes              │
               ▼                                          ▼
┌─────────────────────────────────────────────────────────────────────────┐
│                         Activator (Reflex)                               │
│   ┌─────────────────────────────────────────────────────────────────┐   │
│   │  Object: AirQualityStations                                       │   │
│   │   ├── Property: pm10_value                                        │   │
│   │   ├── Trigger: pm10_value > eu_limit                              │   │
│   │   └── Action: Teams message to #environment-alerts                │   │
│   ├─────────────────────────────────────────────────────────────────┤   │
│   │  Object: AlprDetections                                           │   │
│   │   ├── Property: speed_excess_kmh                                  │   │
│   │   ├── Trigger: speed_excess_kmh >= 30                             │   │
│   │   └── Action: Email to fleet@firma.cz                         │   │
│   ├─────────────────────────────────────────────────────────────────┤   │
│   │  Object: AlprWatchlist                                            │   │
│   │   ├── Property: license_plate                                     │   │
│   │   ├── Trigger: license_plate in (...)                             │   │
│   │   └── Actions: Teams + Email + (volitelné) Power Automate         │   │
│   └─────────────────────────────────────────────────────────────────┘   │
└─────────────────────────────────────────────────────────────────────────┘
21.4

Pre-requisites

Předpoklady

  • B alespoň 1 hodinu běhající (musí být data v b_chmi_clean)
  • D alespoň 5 minut běhající (musí být data v d_alpr_clean)
  • Teams workspace přístupný uživateli, kanál #environment-alerts (vytvořit pokud nemáš)
  • SMTP / Outlook email account v M365 tenantu

Activator artefakt

  1. V workspace: + New item → Activator (název: act_rti_alerts)
  2. Open Activator → bude prázdný
21.5

Setup: Alert 1 — PM10 EU limit breach

Krok 1.1: Get data from KQL stream

  1. V Activator: Get data → Eventstream (nebo KQL Database přímo)
  2. Source: es_b_chmi (nebo kql_rti_demo table b_chmi_clean)
  3. Stream name: chmi_stream

Krok 1.2: Define object

  1. Klik Define object
  2. Object name: AirQualityStations
  3. Identify object by: idRegistration (každá stanice = entity)
  4. Properties: pm10_value ← value (filter pollutant_code == "PM10")
    • V column transformation: where pollutant_code == "PM10" | project idRegistration, value

Krok 1.3: Define trigger

  1. Object AirQualityStations → + New trigger
  2. Name: PM10_Over_EU_Limit
  3. Condition: pm10_value > 50 (EU limit pro PM10 = 50 µg/m³)
  4. Optional rate-limit: „Trigger only once per station per hour" (zabraňuje spam)

Krok 1.4: Action — Teams message

  1. Add action → Send Teams message
  2. Channel: #environment-alerts
  3. Message template:
TEXT
🌫️ PM10 alert!
Station: ${idRegistration}
Value: ${pm10_value} µg/m³ (EU limit: 50)
Time: ${ingest_ts}
  1. Save & Start trigger

Test

  • V Notebook B spusť run_once() (publikuje fresh CHMU data)
  • Pokud nějaká stanice překročí PM10 = 50, do 1-2 min se objeví zpráva v Teams
21.6

Setup: Alert 2 — Severe Speeder (D-ALPR)

Krok 2.1: Get data

  • Source: stream/KQL z d_alpr_clean
  • Filter implicit: is_severe_speeder == true

Krok 2.2: Define object

  • Object name: AlprDetections
  • Identify by: event_id (každý event = entity, nebo vehicle_id + dedup window)

Krok 2.3: Trigger

  • Name: Severe_Speeder
  • Condition: speed_excess_kmh >= 30

Krok 2.4: Action — Email

  • Add action → Send email
  • To: fleet@firma.cz (placeholder)
  • Subject: 🚨 Speeder detected: ${license_plate}
  • Body:
TEXT
ALPR severe speed alert.

License plate: ${license_plate}
Vehicle class: ${vehicle_class}
Speed: ${speed_kmh} km/h (limit ${speed_limit_kmh})
Excess: ${speed_excess_kmh} km/h
Camera: ${camera_id}
Timestamp: ${timestamp}

Live dashboard: https://app.fabric.microsoft.com/groups/<workspace-id>/dashboards/rtd_d_alpr_live
21.7

Setup: Alert 3 — Watchlist Match (D-ALPR)

Krok 3.1: Object — same AlprDetections

Krok 3.2: Trigger — Watchlist

  • Name: Watchlist_Hit
  • Condition: license_plate in ("1AB-2345", "STO-9999", "PHA-0001")
    • V Activator UI: condition expression builder
    • Pro dynamic watchlist (z databáze): use dataflow cel, který obnovuje watchlist parameter every X min

Krok 3.3: Multi-action

  1. Action 1: Teams to #fleet-alerts
  2. Action 2: Email to security@firma.cz
  3. (Optional) Action 3: HTTP webhook → Power Automate flow → SMS via Twilio

Activator Multi-action note

Activator umí chain actions sequentially nebo parallel. Pro production scenario doporuč: first Teams (instant), then email (audit trail), then webhook (escalation).

21.8

Visualization v Activatoru

Activator UI ukazuje:

  • Live event stream — každý nový event projde rules
  • Trigger fires history — kdy a co triggernul
  • Object current state — pro každou entity (stanice, vozidlo) co je aktuální hodnota

V demu ukázat:

  1. Live stream (pomalu plynou events)
  2. Po pár minutách trigger fire history (vidíš že B nebo D pokraly nějaký alert)
  3. Object detail (klikni na konkrétní stanici / vozidlo) — vidíš property history
21.9

Story arc

„Postavili jsme dashboardy. Ale dashboard musí někdo sledovat. RTI dává smysl ve smyčce: detect → decide → act. Activator je 'act' část — bez kódu, no-code rule engine.

Reálný use case: kdyby PM10 v okolí výrobního závodu šlo přes limit, Activator pošle ops týmu Teams alert. Žádný dev tým nemusí psát integrátor."

21.10

Metriky

Metrika Hodnota
Trigger latency (event arrived → action fired) 30-90 sec typicky
Teams delivery < 5 sec po trigger fire
Email delivery 10-60 sec po trigger fire
F2 capacity impact < 0.5 CU/s per Activator
21.11

Limitations & gotchas

  • Activator je v preview / GA roadmap — UI se může změnit. Funkčnost je stable, screenshoty zastarávají.
  • Object cardinality — pro entity = každý event (high cardinality), Activator pomaleji evaluuje. Lepší entity = stable identifier (vehicle_id, station_id).
  • Watermark a out-of-order events — Activator čeká na watermark (~1-5 min) před fire trigger. Není pro sub-sekundové real-time use cases.
  • Action throttling — limity per workspace per hour (typicky 1000 alerts/h). Pro high-frequency triggers nastav rate limit per object.
  • Email/Teams permissions — Activator running entity musí mít M365 perm posílat. Test s vlastním účtem nejdřív.
21.12

Troubleshooting

Problem Fix
Trigger nikdy nefire-ne Stream is empty? Check source has data: KQL b_chmi_clean | where ingest_ts > ago(10m) | count
Teams message nedoorazila Webhook permission. Otevři Activator action → Test connection → log error
Trigger fires ale akce selže Activator activity log → identifikuj cause (auth/throttle/template syntax)
Spam — same trigger fires every event Add rate limit per object (např. 1× za 30min) v trigger settings
Object property je null Source query nevrací sloupec, nebo filter eliminuje rows
21.13

Reuse v jiných kontextech

Use case Pattern
Industrial — sensor offline alert Object = sensor, trigger = last_event_ts < ago(5min)
Retail — low stock alert Object = SKU, trigger = current_stock < reorder_threshold
Healthcare — patient vitals abnormal Object = patient, trigger = heart_rate > 120 OR spo2 < 92
Finance — fraud detection Object = transaction, trigger = amount > threshold AND country in (...)
HR — overtime alert Object = employee, trigger = weekly_hours > 50