-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathconfig-rule.example.yaml
More file actions
95 lines (92 loc) · 2.09 KB
/
config-rule.example.yaml
File metadata and controls
95 lines (92 loc) · 2.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# data integration
# connectors used by sources or sinks
connectors:
- name: conn1
type: amqp
enabled: true
options:
url: amqp://guest:guest@localhost:5672/
- name: mqtt
type: mqtt
enabled: false
options:
clientId: $rule
host: localhost
port: 1883
user: $tio
password: public
cleanSession: false
# data sources
sources:
- name: src1
type: embed-mqtt
enabled: true
options:
topic: $iothub/things/+/presence
qos: 1
- name: src2
type: embed-mqtt
enabled: false
options:
topic: $iothub/user/things/+/property
qos: 1
- name: src-mqtt
type: mqtt
connector: mqtt
options:
topic: $iothub/user/things/+/test
qos: 1
# data sinks
sinks:
- name: sink1
type: amqp
connector: conn1
enabled: true
options:
exchange: exch1
routingKey:
- name: mqtt
type: mqtt
connector: mqtt
enabled: false
options:
topic: $iothub/user/things/${thingId}/publish
# Sources --> Process(filter and transform chain) --> Sinks
# Only json messages are supported
#
# processing message using gojq https://github.com/itchyny/gojq
#
# Message format :
# {
# "thingId": "thignId",
# "topic": "message/mqtt/topic"
# "payload": {
# "a": "a value of message payload"
# }
# }
rules:
- name: test-rule
note: test
enabled: true
sources:
- src1
- src2
- src-mqtt
process:
- type: filter
name: keep-bigger-than-10
# runner: jq # can be omitted when the js field is empty
jq: ".payload.data.a > 10" # should return true of false result
- type: filter
name: keep-less-than-100
# runner: js # can be omitted when the jq field is empty
js: "function run(d) { return d.payload.data.a > 10 }"
- type: transform
name: to-field-x
jq: "{ X: .payload.data.a }" # result like: {"X": 11}
- type: transform
name: to-field-y
js: "function run(d) { return { Y: d.payload.data.a } }" # result like: {"Y": 11}
sinks:
- sink1
- mqtt