|
@@ -40,37 +40,23 @@ EdgeX uses [message bus](https://github.com/edgexfoundry/go-mod-messaging) to ex
|
|
|
|
|
|
## Start to use
|
|
|
|
|
|
-### Pull Kuiper Docker and run
|
|
|
+In out tutorial, we will use [Random Integer Device Service](https://github.com/edgexfoundry/device-random) which is shipped in official released EdgeX, and run rules against the data generated by this sample device service.
|
|
|
|
|
|
-It's **STRONGLY** recommended to use Docker, since related dependency libraries (such ZeroMQ lib) are already installed in Docker images.
|
|
|
+### Run EdgeX Docker instances
|
|
|
|
|
|
-```shell
|
|
|
-docker pull emqx/kuiper:0.3.0
|
|
|
-```
|
|
|
-
|
|
|
-<u>TODO: After offcially releasing of EdgeX Geneva, the Kuiper docker image will be pulled automatically by EdgeX docker composer files. The command will be updated by then.</u>
|
|
|
+After the EdgeX Geneva is offcially released, you can just follow steps in [this doc](https://fuji-docs.edgexfoundry.org/Ch-QuickStart.html) to start the service. But now since Kuiper has not been official released yet, you have to download Docker composer file from [here](https://github.com/edgexfoundry/developer-scripts/blob/master/releases/nightly-build/compose-files/docker-compose-nexus-mongo-no-secty.yml), and then bring up EdgeX Docker instances.
|
|
|
|
|
|
-**Run Docker**
|
|
|
+```shell
|
|
|
+# wget https://github.com/edgexfoundry/developer-scripts/raw/master/releases/nightly-build/compose-files/docker-compose-nexus-mongo-no-secty.yml
|
|
|
|
|
|
-```
|
|
|
-docker run -d --name kuiper emqx/kuiper:0.3.0
|
|
|
+# docker-compose -f ./docker-compose-nexus-redis-no-secty.yml up -d --build
|
|
|
```
|
|
|
|
|
|
-If the docker instance is failed to start, please use ``docker logs kuiper`` to see the log files.
|
|
|
+After all of the Docker instances are started, you can use ``docker ps`` command to verify all of services are runnings correctly.
|
|
|
|
|
|
-Notice 1: The default EdgeX message bus configuration could be updated when bring-up the Docker instance. As listed in below, override the default configurations for message bus server, port and service server address for getting value descriptors in Kuiper instance.
|
|
|
-
|
|
|
-```shell
|
|
|
-docker run -d --name kuiper -e EDGEX_SERVER=10.211.55.2 -e EDGEX_PORT=5563 -e EDGEX_SERVICE_SERVER=http://10.211.55.2:48080 emqx/kuiper:0.3
|
|
|
```
|
|
|
-
|
|
|
-For more detailed supported Docer environment varialbles, please refer to [this link](https://hub.docker.com/r/emqx/kuiper).
|
|
|
-
|
|
|
-*Notice 2: If you'd like to use Kuiper with EdgeX support seperately (without Docker), you could build Kuiper by yourself with ``make pkg_with_edgex`` command.*
|
|
|
-
|
|
|
-### Create a device service
|
|
|
-
|
|
|
-In this tutorial, we use a very simple mock-up device service. Please follow the steps in [this doc](https://fuji-docs.edgexfoundry.org/Ch-GettingStartedSDK-Go.html) to develop and run the random number service.
|
|
|
+TODO: The docker instance list
|
|
|
+```
|
|
|
|
|
|
### Create a stream
|
|
|
|
|
@@ -82,7 +68,7 @@ The next step is to create a stream that can consume data from EdgeX message bus
|
|
|
|
|
|
```shell
|
|
|
curl -X POST \
|
|
|
- http://$your_server:9081/streams \
|
|
|
+ http://$TODO:9081/streams \
|
|
|
-H 'Content-Type: application/json' \
|
|
|
-d '{
|
|
|
"sql": "create stream demo() WITH (FORMAT=\"JSON\", TYPE=\"edgex\")"
|
|
@@ -134,7 +120,7 @@ So the below rule will filter all of ``randomnumber`` that is less than 31. The
|
|
|
|
|
|
```shell
|
|
|
curl -X POST \
|
|
|
- http://$your_server:9081/rules \
|
|
|
+ http://$TODO:9081/rules \
|
|
|
-H 'Content-Type: application/json' \
|
|
|
-d '{
|
|
|
"id": "rule1",
|
|
@@ -157,7 +143,7 @@ You can create a rule file with any text editor, and copy following contents int
|
|
|
|
|
|
```
|
|
|
{
|
|
|
- "sql": "SELECT * from demo where randomnumber > 30",
|
|
|
+ "sql": "SELECT * from demo",
|
|
|
"actions": [
|
|
|
{
|
|
|
"mqtt": {
|
|
@@ -186,13 +172,7 @@ If you want to send analysis result to another sink, please refer to [other sink
|
|
|
Now you can also take a look at the log file under ``log/stream.log``, see detailed info of rule.
|
|
|
|
|
|
```
|
|
|
-time="2020-03-19T10:23:40+08:00" level=info msg="open source node 1 instances" rule=rule1
|
|
|
-time="2020-03-19T10:23:40+08:00" level=info msg="Connect to value descriptor service at: http://localhost:48080/api/v1/valuedescriptor \n"
|
|
|
-time="2020-03-19T10:23:40+08:00" level=info msg="Use configuration for edgex messagebus {{ 0 } {localhost 5563 tcp} zero map[]}\n"
|
|
|
-time="2020-03-19T10:23:40+08:00" level=info msg="Start source demo instance 0 successfully" rule=rule1
|
|
|
-time="2020-03-19T10:23:40+08:00" level=info msg="The connection to edgex messagebus is established successfully." rule=rule1
|
|
|
-time="2020-03-19T10:23:40+08:00" level=info msg="Successfully subscribed to edgex messagebus topic events." rule=rule1
|
|
|
-time="2020-03-19T10:23:40+08:00" level=info msg="The connection to server tcp://broker.emqx.io:1883 was established successfully" rule=rule1
|
|
|
+//TODO
|
|
|
```
|
|
|
|
|
|
### Monitor analysis result
|
|
@@ -201,12 +181,7 @@ Since all of the analysis result are published to ``tcp://broker.emqx.io:1883``
|
|
|
|
|
|
```shell
|
|
|
# mosquitto_sub -h broker.emqx.io -t result
|
|
|
-[{"randomnumber":81}]
|
|
|
-[{"randomnumber":87}]
|
|
|
-[{"randomnumber":47}]
|
|
|
-[{"randomnumber":59}]
|
|
|
-[{"randomnumber":81}]
|
|
|
-...
|
|
|
+//TODO
|
|
|
```
|
|
|
|
|
|
You'll find that only those randomnumber larger than 30 will be published to ``result`` topic.
|
|
@@ -254,6 +229,19 @@ Connecting to 127.0.0.1:20498...
|
|
|
|
|
|
In this tutorial, we introduce a very simple use of EdgeX Kuiper rule engine. If having any issues regarding to use of Kuiper rule engine, you can open issues in EdgeX or Kuiper Github respository.
|
|
|
|
|
|
+### More Excecise
|
|
|
+
|
|
|
+Current rule does not filter any data that are sent to Kuiper, so how to filter data? For example, if you only concern ``Int32`` field value that are great than 30. Please [drop rule](../cli/rules.md) and change the SQL in previous rule file as following.
|
|
|
+
|
|
|
+```
|
|
|
+{
|
|
|
+ "sql": "SELECT * from demo WHERE Int32 > 30",
|
|
|
+ "actions": [...]
|
|
|
+}
|
|
|
+```
|
|
|
+
|
|
|
+After update the rule file, and then deploy the rule again. Please monitor the result topic of MQTT broker, you will find that only ``Int32`` field value that are great than 30 will be sent out.
|
|
|
+
|
|
|
#### Extended Reading
|
|
|
|
|
|
- Read [EdgeX source](../rules/sources/edgex.md) for more detailed information of configurations and data type conversion.
|