Telemetry Pipeline
How data flows from adapters through NATS to storage, rules, and the console.
Telemetry in DataHub follows a publish-subscribe pipeline designed for durability and real-time evaluation.
Pipeline overview
1. Adapter publishes JSON event to NATS
2. JetStream stream DATAHUB stores the message (7-day retention)
3. telemetry-worker persists history + updates Redis latest values
4. rule-worker evaluates matching rules → creates alarms → enqueues actions
5. action-worker delivers notifications
6. Console reads latest values from Redis and history from PostgreSQLEvent contract
Every adapter publishes to subject datahub.telemetry.<plantCode>.<deviceCode>:
{
"eventId": "uuid",
"tagPath": "gebze/press-line-01/s7-1500-01/motor.current",
"plantCode": "gebze",
"machineCode": "press-line-01",
"deviceCode": "s7-1500-01",
"tagCode": "motor.current",
"value": 12.7,
"valueType": "DOUBLE",
"unit": "A",
"quality": "GOOD",
"source": "SIMULATOR",
"sourceTimestamp": "2026-07-21T12:00:00.000Z",
"metadata": {}
}See Adapter contract for full field definitions.
Storage layers
| Layer | Technology | Purpose |
|---|---|---|
| Latest values | Redis hash datahub:latest | Real-time console display |
| Device liveness | Redis datahub:lastseen:<devicePath> | CONNECTED if seen within 15 s |
| History | PostgreSQL TelemetryEvent | Time-series queries and exports |
| Rate metrics | Redis counters | Operations Center throughput KPIs |
Active tags only in live views
The platform distinguishes live data (Redis latest cache) from history (PostgreSQL):
- Inactive tags do not update Redis or receive new history rows — adapters may still publish, but the worker skips them
- Operations Center, UNS Explorer, and device Latest values show active tags only by default
- Deactivating a tag clears its entry from the live Redis mirror
History already stored before deactivation remains queryable. See Plants, machines, and devices — active tags.
Batch ingest (high level)
The telemetry worker batches PostgreSQL writes for higher throughput. Inactive tags are filtered before persistence. For production scale options (batch size, optional plant-scoped consumers), see Production deployment.
Idempotency
eventId is unique in PostgreSQL. Duplicate NATS deliveries are skipped — adapters can safely retry publishes.
Control subjects
Configuration changes trigger reloads without restarting workers:
datahub.rule.changed— rule-worker refreshes its in-memory rule cachedatahub.device.changed— orchestrator reconciles adapter processes
External adapters
Adapters can be written in any language. Publish JSON to NATS using the event contract above. In-process drivers (SIMULATOR, MQTT) are managed by the adapter orchestrator.
