目录:https://my.oschina.net/zgldh/blog/5514606
原文:https://docs.edgexfoundry.org/2.1/walk-through/Ch-WalkthroughExporting/
Exporting your device data 导出你的设备数据
Great, so the data sent by the camera device makes its way to core data. How can that data be sent to an enterprise system or the Cloud? How can that data be used by an edge analytics system (like a rules engine) to actuate on a device?
很好,现在摄像机的数据已经传入了核心数据服务。如何将这些数据转发到其他企业系统或者云服务上呢?这些数据如何被边缘计算系统(例如规则引擎)利用然后反作用于设备呢?
Getting data to the rules engine 将数据传入规则引擎
By default, data is already passed from the core data service to application services (app services) via Redis Pub/Sub messaging. Alternately, the data can be supplied between the two via MQTT. A preconfigured application service is provided with the EdgeX default Docker Compose files that gets this data and routes it to the eKuiper rules engine. The application service is called app-service-rules
(see below). More specifically, it is an app service configurable.
一般来说,数据会默认的从核心数据服务通过 Redis Pub/Sub 消息发送给应用服务。或者也可以用 MQTT 在两者之间传输数据。我们已经在 EdgeX 的默认 Docker Compose 文件里设置好了一个名叫app-service-rules
的应用服务,它会得到核心发来的数据然后路由到 eKuiper rules engine。更详细的内容请参考 应用服务配置。
app-service-rules:
container_name: edgex-app-rules-engine
depends_on:
- consul
- data
environment:
CLIENTS_CORE_COMMAND_HOST: edgex-core-command
CLIENTS_CORE_DATA_HOST: edgex-core-data
CLIENTS_CORE_METADATA_HOST: edgex-core-metadata
CLIENTS_SUPPORT_NOTIFICATIONS_HOST: edgex-support-notifications
CLIENTS_SUPPORT_SCHEDULER_HOST: edgex-support-scheduler
DATABASES_PRIMARY_HOST: edgex-redis
EDGEX_PROFILE: rules-engine
EDGEX_SECURITY_SECRET_STORE: "false"
MESSAGEQUEUE_HOST: edgex-redis
REGISTRY_HOST: edgex-core-consul
SERVICE_HOST: edgex-app-rules-engine
TRIGGER_EDGEXMESSAGEBUS_PUBLISHHOST_HOST: edgex-redis
TRIGGER_EDGEXMESSAGEBUS_SUBSCRIBEHOST_HOST: edgex-redis
hostname: edgex-app-rules-engine
image: edgexfoundry/app-service-configurable:2.0.1
networks:
edgex-network: {}
ports:
- 127.0.0.1:59701:59701/tcp
read_only: true
security_opt:
- no-new-privileges:true
user: 2002:2001
Seeing the data export 查看数据导出
The log level of any EdgeX micro service is set to INFO
by default. If you tune the log level of the app-service-rules micro service to DEBUG
, you can see Events pass through the app service on the way to the rules engine.
所有 EdgeX 微服务的日志都默认是 INFO
级别。如果您将 app-service-rules
微服务的日志级别调整为 DEBUG
,您可以看到事件在该应用服务中通过然后送达规则引擎。
Set the log level 配置日志等级
To set the log level of any service, open the Consul UI in a browser by visiting http://[host]:8500
. When the Consul UI opens, click on the Key/Value tab on the top of the screen.
要设置任何服务的日志级别,请通过浏览器访问 http://[host]:8500
打开管理界面,然后单击屏幕顶部的 Key/Value 选项卡。
On the Key/Value display page, click on edgex
> appservices
> 2.0
> app-rules-engine
> Writable
> LogLevel
. In the Value entry field that presents itself, replace INFO
with DEBUG
and hit the Save
button.
在 Key/Value 页面,依次点击 edgex
> appservices
> 2.0
> app-rules-engine
> Writable
> LogLevel
。在出现的 Value 输入框中,将 INFO
替换为 DEBUG
并点击 Save
按钮。
View the service log 查看服务日志
The log level change will be picked up by the application service. In a terminal window, execute the Docker command below to view the service log.
当日志级别发生改变后,应用服务会感知到。在终端窗口里,执行如下 Docker 命令来查看服务日志。
docker logs -f edgex-app-rules-engine
Now push another event/reading into core data as you did earlier (see Send Event). You should see each new event/reading created by acknowledged by the app service. With the right application service and rules engine configuration, the event/reading data is published to the rules engine topic where it can then be picked up and used by the rules engine service to trigger commands just as you did manually in this walkthrough.
现在重复上一章的动作,推送另一个事件/读数到核心数据服务里。您应该会看到应用服务确认了每个新创建的事件/读数。使用正确的应用程序服务和规则引擎配置,事件/读取数据被发布到规则引擎的一个主题,然后规则引擎服务可以从中获取并使用它来触发命令,就像您在本演练之前章节中手动执行的操作一样。
Exporting data to anywhere 导出数据到任何地方
You can create an additional application service to get the data to another application or service, REST endpoint, MQTT topic, cloud provider, and more. See the Getting Started guide on exporting data for more information on how to use another app service configurable to get EdgeX data to any client.
你可以通过创建更多的应用服务把数据发送到其他的应用或服务,发送到 REST 节点,发送到 MQTT 主题,发送到云服务等等。有关如何通过配置一个其他应用服务把 EdgeX 的数据发送到其他客户端的更多信息,请参阅导出数据的入门指南。
Building your own solutions 构建属于你的方案
Congratulations, you've made it all the way through the Walkthrough tutorial!
恭喜,你已经完成了本教程的全部实战攻略!