通配符主题名称并从所有主题中捕获消息

Wildcard topic names and capturing message from all topics

我们正在使用 AWS IoT。

我们有预定义的主题,(+/device/),设备在其中发布消息。

但有可能,设备可以将消息发布到任何其他主题。

我想计算这些单独的设备发布到所有主题的消息数量并实施限制。

我尝试使用(+/* 或 /)等通配符主题名称创建 IoT 规则,但 none 这些通配符主题似乎有效。

是否有任何通配符主题名称,我可以使用它来捕获来自所有主题的消息?

或者有什么方法可以将所有主题的所有消息转储到 DynamoDB 或 S3 中的某处,并计算特定时间段内来自各个设备的消息数?

I tried to create IoT rules using wildcard topic names like ( +/* or /), but none of these wildcard topics seem to work.

Is there any wildcard topic name, which I can use to capture the messages from all the topics?

+# 是 AWS IoT 规则的相关通配符。参见 https://docs.aws.amazon.com/iot/latest/developerguide/iot-sql-from.html

您可以使用以下语句配置规则以捕获来自所有主题的消息。

SELECT * FROM '#'

Or is there any way to dump all the messages on all the topics somewhere in DynamoDB or S3 and calculate the number of messages from individual devices in a specific time period?

一种方法是根据上述规则创建规则,并在每条消息上传递客户端 ID(使用 clientid() 函数)。此规则的操作可以将客户端 ID 写入 DynamoDB 或 S3。然后可以使用此信息进行计算。

另一种方法可能是将消息和 clientid 写入 Kinesis Data Stream 并使用 Kinesis Data Analytics 检测错误设备。