我们可以在Azure IoT Hub上找到特定设备的数据输入和存储成本吗?

huangapple go评论47阅读模式
英文:

Can we find device-specific data ingress and storage cost on Azure IoT Hub?

问题

我正在寻找任何关于查询Azure IoT Hub监控数据的建议,以便我可以找出每个连接到IoT Hub的设备的数据进入和存储成本。这将帮助我们创建适当的客户计费模型。

从Azure文档中我可以看到IoT Hub的成本是汇总的,还查看了事件中心的文档 - 它也没有提供有关遥测消息的更多细分,以便将其绑定到特定设备。

如果有人尝试过类似的操作或者有关监控查询的任何指导意见,请告诉我。

提前感谢!

英文:

I am looking for any suggestions to query the monitoring data for the Azure IoT Hub, in such a way that I can find out data ingress and storage cost per device connected to the IoT Hub. This will help us in creating a proper charging model for customers.

From the Azure documentation I can see that the costs are aggregate for the IoT Hub, also checked the event hubs documentation - it also doesn't give any more granularity in the telemetry messages, such that it can be bound to a particular device.

If someone has tried something like this or has any pointers related to the monitoring queries, please let me know.

Thanks in advance!

答案1

得分: 1

Azure IoT Hub没有提供一个开箱即用的选项来捕获每个设备传输的遥测数据。实现你所寻找的方式之一是创建一个捕获设备级别遥测计数的设备双属性。你可以让客户端/服务SDK每小时或根据需要访问IoT Hub并更新遥测计数。

以下是如何使用JavaScript更新遥测数据的方式:

// 获取设备的设备双
registry.getTwin('TestDevice4', function (err, twin) {
    if (err) {
        console.error('Failed to get device twin: ' + err.message);
        return;
    }
    // 从设备双中获取telemetryCount属性
    var telemetryCount = twin.properties.desired.telemetryCount;

    // 更新设备双中的telemetryCount属性
    twin.properties.desired.telemetryCount = telemetryCount + 1;

    // 更新设备双
    registry.updateTwin(twin.deviceId, twin, twin.etag, function (err) {
        if (err) {
            console.error('Failed to update device twin: ' + err.message);
            return;
        }

        console.log('Device twin updated successfully');
    });
});

你可以在Azure门户中查看telemetryProperty通过检查设备的设备双来更新。参考下面的图像以供参考。

我们可以在Azure IoT Hub上找到特定设备的数据输入和存储成本吗?

你还可以根据需要在一天/月结束时将telemetryCount属性重置为0,并将数据存储到Blob终结点。

请注意,这个遥测数据只是提供有关推送的遥测消息数量的想法。实际存储成本取决于推送的遥测数据大小。每条消息限制在4KB。请检查传递的消息大小并进行相应分析。

英文:

Azure IoT Hub does not provide an out of the box option to capture the telemetry data transferred per device yet. One of the ways to achieve what you are looking for is by creating a Device Twin property that captures the telemetry count on the device level. You can have the client/service SDK pushing data to the IoT Hub access this property every hour or so, based on your need, and update the telemetry count.

Here is how you can update the telemetry data using javascript

    // Get the device twin for the device
registry.getTwin('TestDevice4', function (err, twin) {
    if (err) {
        console.error('Failed to get device twin: ' + err.message);
        return;
    }
    // Get the telemetryCount property from the device twin
    var telemetryCount = twin.properties.desired.telemetryCount;

    // Update the telemetryCount property in the device twin
    twin.properties.desired.telemetryCount = telemetryCount + 1;

    // Update the device twin
    registry.updateTwin(twin.deviceId, twin, twin.etag, function (err) {
        if (err) {
            console.error('Failed to update device twin: ' + err.message);
            return;
        }

        console.log('Device twin updated successfully');
    });
});

You can see the telemetryPoperty gets updates on the Azure portal by inspecting the Device Twin of the device. Refer the below image for reference.

我们可以在Azure IoT Hub上找到特定设备的数据输入和存储成本吗?

You can further reset the telemetryCount property to 0 at the end of the day/month per your needs and store the data to a blob end point.

Please note that this telemetry data just gives you the idea on number of telemetry messages being pushed. The actual storage cost depends on the size of the telemetry data being pushed as well. Each message is capped at 4KB. Inspect the message size delivered and analyze accordingly.

huangapple
  • 本文由 发表于 2023年6月8日 19:26:15
  • 转载请务必保留本文链接:https://go.coder-hub.com/76431371.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定