Enrichment Nodes
Enrichment nodes thêm dữ liệu vào message từ các entity liên quan — thiết bị, tenant, customer, asset. Message ra khỏi node sẽ có thêm context để các node tiếp theo xử lý.
Originator Attributes
Đọc attributes (client, shared, server) và/hoặc latest telemetry của originator (thiết bị gửi message), gán vào message.
Cấu hình:
Client attributes: cs_model, cs_firmware
Shared attributes: threshold, config
Server attributes: ss_location, ss_owner
Latest telemetry: battery_level
Destination:
Message data— thêm vàomsgpayload (chỉ hoạt động nếu msg là JSON object)Message metadata— thêm vào metadata (luôn string)
Kết quả:
// Trước
msg: { "temperature": 25 }
// Sau (enriched)
msg: {
"temperature": 25,
"cs_model": "DHT22",
"threshold": "30",
"ss_location": "Room-101",
"battery_level": 85
}Tùy chọn: Tell failure if attribute missing — nếu bật, route tới Failure khi thiếu key.
Originator Fields
Đọc các field hệ thống của originator entity và thêm vào metadata:
| Field | Ý nghĩa |
|---|---|
name | Tên thiết bị |
type | Device type |
label | Label |
createdTime | Thời gian tạo |
customerId | ID customer |
Fields to fetch: [name, type, label]
Target: metadata
Sau node, metadata có thêm: metadata.originatorName, metadata.originatorType.
Tenant Attributes
Đọc attributes của tenant sở hữu originator:
Attributes: [smtp_host, api_key, plan_type]
Destination: metadata
Hữu ích khi rule cần biết thông tin cấu hình của tenant để xử lý (vd: dùng SMTP server của tenant để gửi email).
Tenant Details
Thêm thông tin tenant vào metadata:
Fields: [title, email, country, city]
Customer Attributes
Đọc attributes của customer mà originator thuộc về:
Customer attributes: [contact_email, alert_phone]
Destination: metadata
Dùng để gửi thông báo đến đúng customer khi có alarm.
Customer Details
Fields: [title, email, phone, country, city, address]
Destination: metadata
Related Entity Data
Đọc data từ entity có quan hệ với originator:
Direction: FROM
Relation Type: Contains
Entity Type: ASSET
Latest attrs: [building_name, floor_number]
Ví dụ: thiết bị thuộc asset "Building A", node này đọc building_name từ asset đó và thêm vào message.
Originator Telemetry
Đọc lịch sử telemetry của originator:
Keys: [temperature, humidity]
Fetch mode: FIRST / LAST / ALL
Time range: last 1 hour
Fetch modes:
FIRST— giá trị đầu tiên trong khoảngLAST— giá trị cuối cùngALL— mảng tất cả giá trị
Hữu ích cho tính toán delta, average, hoặc phát hiện xu hướng.
Device Profile
Thêm thông tin device profile vào message metadata:
Fields: [profileName, defaultQueueName, defaultRuleChainId]
Calculate Delta
Tính chênh lệch giữa giá trị hiện tại và giá trị trước đó:
Input key: energy_consumption
Output key: energy_delta
Tell failure if previous value is absent: ✓
Rất hữu ích cho đồng hồ điện/nước (tính lượng tiêu thụ từ chỉ số tích lũy).
Ví dụ:
t1: energy_consumption = 1000 kWh
t2: energy_consumption = 1015 kWh
→ energy_delta = 15 kWh
Ví dụ pipeline enrichment
[Telemetry] → [Originator Attributes: threshold, location]
↓
[Customer Attributes: alert_email, alert_phone]
↓
[Script Filter: msg.temperature > metadata.threshold]
↓ True
[Send Email to metadata.alert_email]
Node enrichment giúp rule engine hoạt động dynamic — không hard-code giá trị, đọc từ entity configuration.