如何对来自 IOT Central 数据导出、通过事件中心路由并在 TSI 中使用的遥测数据进行类型和建模?
使用 IOT Central 数据导出到事件中心时,您的消息格式为:
{
"applicationId": "A-GUID",
"component": null,
"deviceId": "AN-ID",
"enqueuedTime": "2022-02-23T20:34:11.0400000Z",
"enrichments": {},
"messageProperties": {},
"messageSource": "telemetry",
"module": null,
"schema": "default@v1",
"telemetry": [
{
"label": "temp",
"value": "33"
},
{
"label": "watts",
"value": 2183
}
...
"templateId": "A-TEMPLATE-ID",
"ts": "2022-02-23T20:26:39.0000000Z",
"EventProcessedUtcTime": "2022-02-23T20:37:53.1779856Z",
"PartitionId": 0,
"EventEnqueuedUtcTime": "2022-02-23T20:34:12.5810000Z"
}
我的问题是如何将遥测属性解压为 TSI 可以视为类型的内容?
类型似乎依赖于更扁平的命名结构,例如 $event.telemety.watts
,并且无法查询 $event.telemetrty.label == "watts
。
我的一个想法是我可能需要在数据到达 TSI 之前,通过使用入站事件中心、然后使用扁平化架构的函数以及 TSI 从中读取的出站事件中心来转换此数据。
When using IOT Central data export to Event Hub, you have a message format which is:
{
"applicationId": "A-GUID",
"component": null,
"deviceId": "AN-ID",
"enqueuedTime": "2022-02-23T20:34:11.0400000Z",
"enrichments": {},
"messageProperties": {},
"messageSource": "telemetry",
"module": null,
"schema": "default@v1",
"telemetry": [
{
"label": "temp",
"value": "33"
},
{
"label": "watts",
"value": 2183
}
...
"templateId": "A-TEMPLATE-ID",
"ts": "2022-02-23T20:26:39.0000000Z",
"EventProcessedUtcTime": "2022-02-23T20:37:53.1779856Z",
"PartitionId": 0,
"EventEnqueuedUtcTime": "2022-02-23T20:34:12.5810000Z"
}
My question is how do you unpack the Telemetry property into something which TSI can see as Types?
The Type seems to rely on a flatter naming structure, like $event.telemety.watts
, and there is no way to query for $event.telemetrty.label == "watts
.
My one thought is that I may need to transform this data before it gets to TSI by using an inbound event hub, then a function to flatten the schema and an outbound event hub which is what TSI reads from.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
想通了。 IoT Central 数据导出中有一个(对我来说)新的转换功能。
我们使用以下规则来转换遥测数据。
遥测:.telemetry |地图({ (.name|tostring): .value }) |添加
Figured it out. There's a new (to me) Transform feature in IoT Central Data Export.
We used the following rule to transform the telemetry.
telemetry: .telemetry | map({ (.name|tostring): .value }) | add