Architecture du pipeline
Open-Meteo API
données météo live
lat / lon en argument
lat / lon en argument
→
Producer
current_weather.pyEx 1 & 3, envoie JSON
toutes les N secondes
toutes les N secondes
→
Kafka topic
weather_stream
→
Spark
spark_transform.pyEx 4, alertes vent / chaleur
wind_alert_level · heat_alert_level→
Kafka topic
weather_transformed
→
Spark
spark_aggregates.pyEx 5, fenêtre glissante 5 min
moyenne · min · max · alertes
moyenne · min · max · alertes
→
Consumer / Dashboard
Ex 2, affichage temps réel
| Exercice | Fichier | Ce que ça fait | Statut |
|---|---|---|---|
| Ex 1 | create_topics.py · produce_hello.py | Crée weather_stream et envoie {"msg":"Hello Kafka"} | ✔ fait |
| Ex 2 | consumer.py | Lit un topic passé en argument, affiche en temps réel | ✔ fait |
| Ex 3 | current_weather.py | Interroge Open-Meteo (lat/lon) → weather_stream | ✔ fait |
| Ex 4 | spark_transform.py | Streaming Spark → alertes vent & chaleur → weather_transformed | ✔ fait |
| Ex 5 | spark_aggregates.py | Fenêtre glissante 5 min : moy/min/max température, alertes par type et par ville | ✔ fait |
Exercice 1 : topic et message statique
Topic créés
Message Hello Kafka
Exercice 2 : consommateur Kafka
Le script consumer.py --topic <topic> lit les messages du topic passé en argument et les affiche en temps réel (JSON).
Exercice 3 : données météo en direct (Open-Meteo)
Messages capturés dans weather_stream : température, vent (m/s), coordonnées et horodatage pour chaque ville.
| Offset | Ville | Pays | Temp °C | Vent m/s | Event time | Source |
|---|
Exercice 4 : transformation et détection d'alertes (Spark)
Alertes de vent
level_0 < 10 m/s, vent faible
level_1 10-20 m/s, vent modéré
level_2 > 20 m/s, vent fort
Alertes de chaleur
level_0 < 25 °C, température normale
level_1 25-35 °C, chaleur modérée
level_2 > 35 °C, canicule
Sortie de spark_transform.py dans weather_transformed. Colonnes ajoutées : event_time, wind_alert_level, heat_alert_level.
| Ville | Pays | Temp °C | Vent m/s | Vent alert | Chaleur alert | Event time |
|---|
Exercice 5 : agrégats temps réel (fenêtre glissante 5 min, slide 1 min)
Alertes L1/L2 par type + stats température
| Fenêtre début | Fenêtre fin | Alertes vent | Alertes chaleur | Total | Moy °C | Min | Max | Évts |
|---|
Alertes par ville / pays
| Fenêtre début | Ville | Pays | Alertes | Moy °C | Évts |
|---|