Azure IoT Central で PoC を実施させていただいていたのですが。その際に踏んだ事象でございます。
下記の記事などを参考にすると、デバイスからは入れ子になった JSON でデータが送られてきます。
送られてくる JSON のイメージは下記の通り。
{ "applicationId":"xxxxx", "component":"SensorAltitude", "deviceId":"cl0evatmso", "enqueuedTime":"2023-11-30T02:42:14.515Z", "enrichments":{"workingSet":"hogehoge"}, "messageProperties":{"iothub-creation-time-utc":"2023-11-30T02:42:14.442Z"}, "messageSource":"telemetry", "module":null, "schema":"default@v1", "telemetry": { "SensorAltitude":38.88142843434689, }, "templateId":"dtmi:Espressif:o88xsnugnyr" }
そして、Azure IoT Central には Azure Data Explorer (ADX) へエクスポートする機能があるのですが…
どうしても、ADX 側へエクスポートする際に JSON が入れ子になっていると、その属性を ADX 側のテーブルへマッピングしてくれない様子。
そのため、エクスポート時の書き換えルールで入れ子にならないように指定する必要がありました。
import "iotc" as iotc;
{
schema: "default@v1",
applicationId: .applicationId,
deviceId: .device.id,
templateId: .device.templateId,
messageSource: .messageSource,
enqueuedTime: .enqueuedTime,
SensorMagnetX: .telemetry | iotc::find(.name == "SensorMagnetX").value,
SensorMagnetY: .telemetry | iotc::find(.name == "SensorMagnetY").value,
SensorMagnetZ: .telemetry | iotc::find(.name == "SensorMagnetZ").value,
... <送付される可能性のある属性の分、すべて記載する> ..,
messageProperties: .messageProperties,
enrichments: .enrichments,
component: .component,
module: .module
}
IoT Central では実現できない分析などを行いたいときは ADX を活用したりすると思います。
もし、同じポイントに当たった方は参考にしていただければ幸いです。