Rules
The following 3 parameters are required for creating a rule.
The identification of the rule. The rule name cannot be duplicated in the same eKuiper instance.
The sql query to run for the rule.
The current options includes:
For detail about and checkpointInterval
, please check state and fault tolerance.
- eKuiper provides embeded following 3 sources,
- MQTT source, see for more detailed info.
- EdgeX source by default is shipped in docker images, but NOT included in single download binary files, you use
make pkg_with_edgex
command to build a binary package that supports EdgeX source. Please see for more detailed info. - HTTP pull source, regularly pull the contents at user’s specified interval time, see here for more detailed info.
- Sources can be customized, see for more detailed info.
Currently, below kinds of sinks/actions are supported:
- log: Send the result to log file.
- : Send the result to an MQTT broker.
- edgex: Send the result to EdgeX message bus.
- : Send the result to a Rest HTTP server.
- nop: Send the result to a nop operation.
Each action can define its own properties. There are several common properties:
User can refer to for more detailed scenarios. If sendSingle is true, the data template will execute against a record; Otherwise, it will execute against the whole array of records. Typical data templates are:
For example, we have the sink input as
"ab" : "hello1",
},{
"ab" : "hello2",
}}
In sendSingle=true mode:
- Print out the whole record
"dataTemplate": "{\"content\":{{json .}}}",
"dataTemplate": "{\"content\":\"{{.ab}}\"}",
In sendSingle=false mode:
- Print out the whole record array
"dataTemplate": "{\"content\":{{json .}}}",
- Print out the first record
- Print out the field ab of the first record
"dataTemplate": "{\"content\":{{index . 0 \"ab\"}}}",
- Print out field ab of each record in the array to html format
Actions could be customized to support different kinds of outputs, see extension for more detailed info.
With the help of template functions, users can do a lot of transformation including formation, simple mathematics, encoding etc. The supported functions in eKuiper template includes:
- Go built-in .
- An abundant extended function set from sprig library.
- eKuiper extended functions.
eKuiper extends several functions that can be used in data template.
- (deprecated)
json para1
: Thejson
function is used for convert the map content to a JSON string. UsetoJson
from sprig instead. - (deprecated)
base64 para1
: Thebase64
function is used for encoding parameter value to a base64 string. Convert the pramater to string type and useb64enc
from sprig instead.
In the sink, it is common to fetch a property value from the result data to achieve dynamic output. For example, to write data into a dynamic topic of mqtt. The dynamic properties will be parsed as a . In below example, the sink topic is gotten from the selected topic using data template.