docs: Update data flow diagram - 3 IoT Agents per broker, Orion-LD, QuantumLeap
This commit is contained in:
@@ -1,236 +1,144 @@
|
|||||||
# Smart City Digital Twin Martinique — Diagramme des Flux de Données
|
# Smart City Digital Twin - Data Flow Diagram (Updated 2026-05-06)
|
||||||
|
|
||||||
**Dernière mise à jour :** 06 Mai 2026
|
## Architecture évoluée : 1 IoT-Agent par broker MQTT
|
||||||
**Projet :** Smart City Digital Twin Martinique
|
|
||||||
**Architecture :** IoT-Agent intégré, QuantumLeap + CrateDB pour l'analyse avancée
|
|
||||||
|
|
||||||
---
|
```
|
||||||
|
┌─────────────────────────────────────────────────────────────────────────────┐
|
||||||
## Architecture Globale (Mise à jour 06/05/2026)
|
│ Smart City Simulator (Python) │
|
||||||
|
│ Publie sur 3 brokers MQTT avec format IoT-Agent JSON │
|
||||||
```mermaid
|
└──────────┬────────────────────┬──────────────────────┬───────────────────┘
|
||||||
graph TB
|
│ │ │
|
||||||
subgraph Simulateur["🖥️ Simulateur (Host Python)"]
|
▼ ▼ ▼
|
||||||
SIM[Smart City Simulator<br/>10 capteurs<br/>Intervalle: configurable]
|
┌──────────────────┐ ┌──────────────────┐ ┌──────────────────┐
|
||||||
end
|
│ EMQX Broker │ │ Mosquitto Broker │ │ BunkerM Broker │
|
||||||
|
│ (port 11883) │ │ (port 1883) │ │ (port 1900) │
|
||||||
subgraph MQTT_Brokers["📡 MQTT Brokers"]
|
│ Topic: smart- │ │ Topic: smart- │ │ Topic: smart- │
|
||||||
EMQ[EMQX<br/>port 11883]
|
│ city-api-key/ │ │ city-api-key/ │ │ city-api-key/ │
|
||||||
MOS[Mosquitto<br/>port 1883]
|
│ {id}/attrs │ │ {id}/attrs │ │ {id}/attrs │
|
||||||
BUN[BunkerM<br/>port 1900<br/>MQTTS/TLS]
|
└────────┬─────────┘ └────────┬─────────┘ └────────┬─────────┘
|
||||||
end
|
│ │ │
|
||||||
|
▼ ▼ ▼
|
||||||
subgraph IoT_Agent["🤖 IoT Agent (NGSI-LD)"]
|
┌──────────────────┐ ┌──────────────────┐ ┌──────────────────┐
|
||||||
IOTA[IoT Agent JSON<br/>port 4041<br/>Transforme MQTT → NGSI-LD]
|
│ IoT-Agent-EMQX │ │IoT-Agent-Mosquitto│ │IoT-Agent-BunkerM │
|
||||||
end
|
│ Port: 4041 │ │ Port: 4042 │ │ Port: 4043 │
|
||||||
|
│ Apikey: smart- │ │ Apikey: smart- │ │ Apikey: smart- │
|
||||||
subgraph CB["🔗 Context Brokers (NGSI-LD)"]
|
│ city-api-key │ │ city-api-key │ │ city-api-key │
|
||||||
ORI[Orion-LD<br/>NGSI-LD<br/>port 1026]
|
└────────┬─────────┘ └────────┬─────────┘ └────────┬─────────┘
|
||||||
STE[Stellio<br/>NGSI-LD<br/>port 8080]
|
│ │ │
|
||||||
FRO[FROST-Server<br/>SensorThings<br/>port 8080]
|
└───────────────────────┴──────────────────────┘
|
||||||
end
|
│
|
||||||
|
▼
|
||||||
subgraph Analytics["📈 Analytics & Time-Series"]
|
┌─────────────────────┐
|
||||||
QL[QuantumLeap<br/>NGSI-LD → CrateDB<br/>port 8668]
|
│ Orion-LD Context │
|
||||||
CRATEDB[CrateDB<br/>PostgreSQL-compatible<br/>port 4200/5432]
|
│ Broker (port 1026)│
|
||||||
end
|
│ MongoDB backend │
|
||||||
|
└─────────┬───────────┘
|
||||||
subgraph Storage["💾 Stockage & Métriques"]
|
│
|
||||||
INF[InfluxDB<br/>Bucket: iot_data<br/>port 8086]
|
│ Subscription (id: 69fbb09af55b82cad2a38008)
|
||||||
PRO[Prometheus<br/>Scrape: /metrics<br/>port 9090]
|
│ Forward to QuantumLeap
|
||||||
GEO[GeoServer<br/>WMS/WFS/WMTS<br/>port 8080]
|
▼
|
||||||
end
|
┌─────────────────────┐
|
||||||
|
│ QuantumLeap │
|
||||||
subgraph IoT_Platform["🏢 Plateforme IoT"]
|
│ (port 8668) │
|
||||||
ORM[OpenRemote Manager<br/>MQTT Agent<br/>port 8080]
|
│ /v2/op/notify │
|
||||||
KC[Keycloak<br/>port 8080]
|
└─────────┬───────────┘
|
||||||
end
|
│
|
||||||
|
▼
|
||||||
subgraph VIZ["📊 Visualisation"]
|
┌─────────────────────┐
|
||||||
GRA[Grafana<br/>Dashboards<br/>port 3001]
|
│ CrateDB │
|
||||||
MAP[MapStore<br/>WMS/WFS<br/>port 8080]
|
│ (ports 5432/4200)│
|
||||||
end
|
│ DB: quantumleap │
|
||||||
|
└─────────┬───────────┘
|
||||||
%% ── Flux Simulateur ──────────────────────────────────────────
|
│
|
||||||
SIM -->|"1️⃣ MQTT publish<br/>city/sensors/{type}/{id}"| EMQ
|
▼
|
||||||
SIM -->|"1️⃣ MQTT publish"| MOS
|
┌─────────────────────┐
|
||||||
SIM -->|"1️⃣ MQTT publish"| BUN
|
│ Grafana │
|
||||||
SIM -->|"5️⃣ InfluxDB v2 API<br/>async non-bloquant"| INF
|
│ (port 3001) │
|
||||||
|
│ Datasource: │
|
||||||
%% ── Flux MQTT → IoT Agent ──────────────────────────────────
|
│ CrateDB-SmartCity│
|
||||||
EMQ -->|"MQTT subscribe<br/>city/sensors/#"| IOTA
|
└─────────────────────┘
|
||||||
MOS -->|"MQTT subscribe"| IOTA
|
|
||||||
BUN -->|"MQTT subscribe"| IOTA
|
|
||||||
|
|
||||||
%% ── Flux IoT Agent → Context Brokers ───────────────────────
|
|
||||||
IOTA -->|"2️⃣ NGSI-LD POST<br/>/ngsi-ld/v1/entities"| ORI
|
|
||||||
IOTA -->|"2️⃣ NGSI-LD POST"| STE
|
|
||||||
|
|
||||||
%% ── Flux Context Brokers → QuantumLeap ───────────────────
|
|
||||||
ORI -->|"NGSI-LD Subscription<br/>→ QuantumLeap"| QL
|
|
||||||
STE -->|"NGSI-LD Subscription<br/>→ QuantumLeap"| QL
|
|
||||||
|
|
||||||
%% ── Flux QuantumLeap → CrateDB ────────────────────────────
|
|
||||||
QL -->|"Insert<br/>PostgreSQL wire"| CRATEDB
|
|
||||||
|
|
||||||
%% ── Visualisation ───────────────────────────────────────────
|
|
||||||
CRATEDB -->|"PostgreSQL Datasource"| GRA
|
|
||||||
INF -->|"Datasource Flux IoT"| GRA
|
|
||||||
ORI -->|"NGSI-LD Datasource"| GRA
|
|
||||||
STE -->|"NGSI-LD Datasource"| GRA
|
|
||||||
GEO -->|"WMS/WMTS"| MAP
|
|
||||||
ORM -->|MapSettings<br/>Martinique| MAP
|
|
||||||
ORM -->|"Live assets<br/>REST"| GRA
|
|
||||||
|
|
||||||
%% ── OpenRemote MQTT Agent ───────────────────────────────────
|
|
||||||
EMQ -->|"6️⃣ Subscribe<br/>city/sensors/#"| ORM
|
|
||||||
MOS -->|"6️⃣ Subscribe"| ORM
|
|
||||||
BUN -->|"6️⃣ Subscribe"| ORM
|
|
||||||
|
|
||||||
%% ── Métriques Prometheus ────────────────────────────────────
|
|
||||||
SIM -->|"7️⃣ /metrics<br/>port 8001"| PRO
|
|
||||||
EMQ -->|"/api/v5/metrics"| PRO
|
|
||||||
STE -->|"/actuator/prometheus"| PRO
|
|
||||||
INF -->|"/metrics"| PRO
|
|
||||||
ORM -->|"/actuator/prometheus"| PRO
|
|
||||||
GRA -->|"/metrics"| PRO
|
|
||||||
IOTA -->|"/metrics"| PRO
|
|
||||||
QL -->|"/metrics"| PRO
|
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
## Flux de données (Step-by-step)
|
||||||
|
|
||||||
## Flux Détaillés (Mise à jour 06/05/2026)
|
1. **Simulator** publie sur 3 brokers MQTT (EMQX:11883, Mosquitto:1883, BunkerM:1900)
|
||||||
|
- Topic: `smartcity-api-key/{device_id}/attrs`
|
||||||
|
- Format: `{"NO2": 45.5, "temperature": 26.0, "humidity": 70.0}`
|
||||||
|
|
||||||
### 1️⃣ Flux MQTT — Brokers
|
2. **3 IoT-Agents** (un par broker) reçoivent les messages
|
||||||
| Broker | Port | Protocol | Topics |
|
- iot-agent-emqx (port 4041) ← EMQX
|
||||||
|--------|------|----------|--------|
|
- iot-agent-mosquitto (port 4042) ← Mosquitto
|
||||||
| EMQX | 11883 | MQTT | `city/sensors/{type}/{id}` |
|
- iot-agent-bunkerm (port 4043) ← BunkerM
|
||||||
| Mosquitto | 1883 | MQTT | `city/sensors/{type}/{id}` |
|
- Chaque IoT-Agent a le service `smartcity-api-key` configuré
|
||||||
| BunkerM | 1900 | MQTTS (TLS) | `city/sensors/{type}/{id}` |
|
- Chaque IoT-Agent a le device `airquality_001` enregistré
|
||||||
|
|
||||||
Le simulateur publie simultanément sur les 3 brokers vers **IoT Agent**.
|
3. **Orion-LD** reçoit les entités NGSI-v2
|
||||||
|
- URL: `http://smart-city-orion-ld:1026`
|
||||||
|
- Entité: `urn:ngsi-ld:AirQualityObserved:airquality_001`
|
||||||
|
- Type: `AirQualityObserved`
|
||||||
|
|
||||||
### 2️⃣ Flux IoT Agent — NGSI-LD
|
4. **Subscription Orion-LD → QuantumLeap**
|
||||||
- **IoT Agent JSON** : Réception MQTT → Transformation en entités NGSI-LD
|
- ID: `69fbb09af55b82cad2a38008`
|
||||||
- **Port** : `4041`
|
- Description: "Forward AirQualityObserved to QuantumLeap"
|
||||||
- **Configuration** :
|
- Notify URL: `http://smart-city-quantumleap:8668/v2/op/notify`
|
||||||
```bash
|
- Attrs: NO2, temperature, humidity
|
||||||
# Enregistrement service
|
|
||||||
curl -X POST http://localhost:4041/iot/services \
|
|
||||||
-H 'Content-Type: application/json' \
|
|
||||||
-H 'fiware-service: smartcity' \
|
|
||||||
-d '{"services": [{"apikey": "smartcity-api-key", "cbroker": "http://orion-ld:1026", "entity_type": "Device", "ngsi_version": "ld"}]}'
|
|
||||||
```
|
|
||||||
- **Entités créées dans** : Orion-LD (port 1026) et Stellio (port 8080)
|
|
||||||
|
|
||||||
### 3️⃣ Flux Context Brokers → QuantumLeap → CrateDB
|
5. **QuantumLeap** stocke dans **CrateDB**
|
||||||
1. **Orion-LD** / **Stellio** : Reçoivent les entités NGSI-LD de IoT Agent
|
- Table: `quantumleap.etairqualityobserved`
|
||||||
2. **QuantumLeap** (port 8668) : Souscrit aux mises à jour NGSI-LD via Subscription
|
- Colonnes: entity_id, time_index, NO2, temperature, humidity
|
||||||
3. **CrateDB** (port 5432/4200) : Stockage temporel PostgreSQL-compatible
|
|
||||||
4. **Grafana** : Dashboards connectés à CrateDB (PostgreSQL datasource)
|
|
||||||
|
|
||||||
### 4️⃣ Flux InfluxDB — Temps Réel
|
6. **Grafana** visualise les données
|
||||||
- **API** : `http://localhost:8086/api/v2/write`
|
- Datasource: `CrateDB-SmartCity` (ID: 23)
|
||||||
- **Bucket** : `iot_data`
|
- URL: `smart-city-cratedb:5432`
|
||||||
- **Org** : `digitribe`
|
- Database: `quantumleap`
|
||||||
- **Mode** : Asynchrone (thread daemon) pour ne pas bloquer le publish MQTT
|
|
||||||
|
|
||||||
### 5️⃣ OpenRemote — MQTT Agent
|
## Services et Devices (provisionnés)
|
||||||
L'agent MQTT d'OpenRemote souscrit aux topics `city/sensors/#` sur les brokers MQTT. Les payloads sont automatiquement parsés et les attributs des assets sont mis à jour.
|
|
||||||
|
|
||||||
### 6️⃣ Flux Prometheus — Métriques
|
### IoT-Agent-EMQX (port 4041)
|
||||||
| Service | Endpoint `/metrics` | Statut |
|
- Service: `smartcity-api-key` → Orion-LD (`http://smart-city-orion-ld:1026`)
|
||||||
|---------|---------------------|--------|
|
- Device: `airquality_001` → `urn:ngsi-ld:AirQualityObserved:airquality_001`
|
||||||
| Simulator | `localhost:8001` | ✅ |
|
|
||||||
| EMQX | `emqx_emqx_1:8081/api/v5/metrics` | ✅ |
|
|
||||||
| Stellio | `stellio-api-gateway:8080/actuator/prometheus` | ✅ |
|
|
||||||
| InfluxDB | `smart-city-influxdb:8086/metrics` | ✅ |
|
|
||||||
| OpenRemote | `openremote-manager-1:8080/actuator/prometheus` | ✅ |
|
|
||||||
| Grafana | `smart-city-grafana:3000/metrics` | ✅ |
|
|
||||||
| IoT Agent | `iot-agent:4041/metrics` | ⚠️ À vérifier |
|
|
||||||
| QuantumLeap | `quantum-leap:8668/metrics` | ⚠️ À vérifier |
|
|
||||||
|
|
||||||
---
|
### IoT-Agent-Mosquitto (port 4042)
|
||||||
|
- Service: `smartcity-api-key` → Orion-LD (`http://smart-city-orion-ld:1026`)
|
||||||
|
- Device: `airquality_001` → `urn:ngsi-ld:AirQualityObserved:airquality_001`
|
||||||
|
|
||||||
## Nouveaux Composants (06/05/2026)
|
### IoT-Agent-BunkerM (port 4043)
|
||||||
|
- Service: `smartcity-api-key` → Orion-LD (`http://smart-city-orion-ld:1026`)
|
||||||
|
- Device: `airquality_001` → `urn:ngsi-ld:AirQualityObserved:airquality_001`
|
||||||
|
|
||||||
### 🤖 IoT Agent JSON
|
## Sous-domaines (Traefik)
|
||||||
- **Rôle** : Pont entre MQTT et NGSI-LD (Orion-LD / Stellio)
|
|
||||||
- **Port** : 4041
|
|
||||||
- **Statut** : ❌ En cours de réparation (erreur MongoDB)
|
|
||||||
- **Correction** : Fournir `IOTA_MONGO_URL=mongodb://mongodb:27017/iotagent`
|
|
||||||
|
|
||||||
### 📈 QuantumLeap
|
- `iot-agent-emqx.digitribe.fr` → IoT-Agent-EMQX (port 4041)
|
||||||
- **Rôle** : Analytics NGSI-LD → CrateDB
|
- `iot-agent-mosquitto.digitribe.fr` → IoT-Agent-Mosquitto (port 4042)
|
||||||
- **Port** : 8668
|
- `iot-agent-bunkerm.digitribe.fr` → IoT-Agent-BunkerM (port 4043)
|
||||||
- **Statut** : ✅ Fonctionnel (interne), port non exposé sur l'hôte
|
- `orion-ld.digitribe.fr` → Orion-LD (port 1026)
|
||||||
- **Action** : Exposer le port dans docker-compose
|
- `quantum-leap.digitribe.fr` → QuantumLeap (port 8668)
|
||||||
|
- `grafana.digitribe.fr` → Grafana (port 3001)
|
||||||
|
|
||||||
### 🗄️ CrateDB
|
## Test du flux complet
|
||||||
- **Rôle** : Base de données temporelle PostgreSQL-compatible
|
|
||||||
- **Port** : 4200 (UI), 5432 (PostgreSQL)
|
|
||||||
- **Statut** : ✅ Opérationnel
|
|
||||||
- **Usage** : Stockage des séries temporelles depuis QuantumLeap
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Tableau Récapitulatif (Mise à jour)
|
|
||||||
|
|
||||||
| Composant | Technologie | Port | Statut |
|
|
||||||
|-----------|-------------|------|--------|
|
|
||||||
| Simulator | Python + paho-mqtt | Host:8001 (metrics) | ✅ Actif |
|
|
||||||
| EMQX | MQTT Broker | 11883 | ✅ Connecté |
|
|
||||||
| Mosquitto | MQTT Broker | 1883 | ✅ Connecté |
|
|
||||||
| BunkerM | MQTTS Broker | 1900 | ✅ Connecté |
|
|
||||||
| **IoT Agent** | **NGSI-LD Bridge** | **4041** | **❌ Erreur MongoDB** |
|
|
||||||
| Orion-LD | NGSI-LD Broker | 1026 | ⚠️ À vérifier |
|
|
||||||
| Stellio | NGSI-LD Broker | 8080 | ⚠️ Ports occupés par OpenRemote |
|
|
||||||
| FROST-Server | SensorThings API | 8080 | ⚠️ À vérifier |
|
|
||||||
| **QuantumLeap** | **NGSI-LD → CrateDB** | **8668** | **✅ Interne** |
|
|
||||||
| **CrateDB** | **PostgreSQL Time-Series** | **4200/5432** | **✅ Opérationnel** |
|
|
||||||
| OpenRemote | IoT Platform | 8080 | ⚠️ 403 (Service Account) |
|
|
||||||
| InfluxDB | Time Series DB | 8086 | ✅ Bucket iot_data |
|
|
||||||
| Grafana | Visualisation | 3001 | ✅ Dashboards + CrateDB |
|
|
||||||
| GeoServer | Geo Data | 8080 | ✅ REST OK |
|
|
||||||
| MapStore | Cartographie | 8080 | ✅ WMS/WMTS |
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Actions Prioritaires
|
|
||||||
|
|
||||||
1. **Corriger IoT Agent** : Ajouter MongoDB et configurer `IOTA_MONGO_URL`
|
|
||||||
2. **Exposer QuantumLeap** : Mapper le port 8668 dans docker-compose
|
|
||||||
3. **Déployer Orion-LD** : Créer le service s'il n'existe pas
|
|
||||||
4. **Libérer les ports** : Résoudre le conflit Stellio/OpenRemote sur le port 8080
|
|
||||||
5. **Configurer CrateDB** : Créer les tables pour QuantumLeap
|
|
||||||
6. **Mettre à jour le simulateur** : `ENABLE_PULSAR=false` (recommandé)
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Commandes Utiles
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Vérifier IoT Agent
|
# 1. Publier un message MQTT (simuler le simulateur)
|
||||||
curl -s http://localhost:4041/iot/services -H 'fiware-service: smartcity'
|
mosquitto_pub -h localhost -p 11883 -t "smartcity-api-key/airquality_001/attrs" \
|
||||||
|
-m '{"NO2": 50.5, "temperature": 30.0, "humidity": 90.0}'
|
||||||
|
|
||||||
# Vérifier QuantumLeap
|
# 2. Vérifier qu'Orion-LD a reçu l'entité
|
||||||
curl -s http://localhost:8668/version
|
curl -s http://localhost:1026/v2/entities -w "\nHTTP %{http_code}\n"
|
||||||
|
|
||||||
# Vérifier CrateDB
|
# 3. Vérifier que QuantumLeap a reçu la notification
|
||||||
psql -h localhost -p 5432 -U crate -c "SELECT * FROM ql_entities LIMIT 5;"
|
docker logs smart-city-quantumleap --tail 20 | grep -i "notify\|airquality"
|
||||||
|
|
||||||
# Vérifier Orion-LD
|
# 4. Vérifier CrateDB
|
||||||
curl -s http://localhost:1026/version
|
docker exec smart-city-cratedb crash -c "SELECT * FROM quantumleap.etairqualityobserved LIMIT 5;"
|
||||||
|
|
||||||
# Voir les logs IoT Agent
|
# 5. Vérifier Grafana
|
||||||
docker logs smart-city-iot-agent --tail 30
|
curl -s http://localhost:3001/api/datasources -u admin:Digitribe972 | jq '.[] | select(.type=="postgres") | .name'
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
## Fichiers modifiés (2026-05-06)
|
||||||
|
|
||||||
**Fichiers associés :**
|
- `docker-compose.iot-agent.yml` : 3 instances IoT-Agent (emqx, mosquitto, bunkerm)
|
||||||
- Simulateur : `~/smart-city-digital-twin-martinique/simulator.py`
|
- `docker-compose.orion-ld.yml` : Orion-LD avec MongoDB existant
|
||||||
- Dashboard Grafana : `~/smart-city-digital-twin-martinique/grafana_dashboard_smartcity.json`
|
- `docker-compose.quantumleap.yml` : Variables CRATE_HOST/PORT (fix)
|
||||||
- Ce diagramme : `~/smart-city-digital-twin-martinique/data-flow-diagram.md`
|
- `simulator.py` : Publication sur 3 brokers avec format IoT-Agent
|
||||||
- Session Resume : `~/smart-city-digital-twin-martinique/session_resume_2026-05-07.md`
|
- `data-flow-diagram.md` : Ce fichier (mis à jour)
|
||||||
|
|||||||
Reference in New Issue
Block a user