来自物联网规则的Timestream中维度(空值)的错误。

0

【以下的问题经过翻译处理】 你好: 我正在尝试从AWS IoT插入数据到Timestream,我创建了下面的规则:

SELECT * FROM 'dataTopic'
ACTIONS: 
将消息写入Timestream: 
     数据库:test, 
     表: sensors, 
     维度名:device, 
     维度值:${device}
将消息转发到AWS IoT主题:test
错误操作:
将消息转发到AWS IoT主题:error

然后以如下方式发布数据:

{
       "device": "abc123",
       "temperature": "24.50",
       "humidity": "49"
}


效果很好。 现在,我的真实数据 实际上是这样的:

{
  "state": {
    "reported": {
       "device": "abc123",
       "temperature": "24.50",
       "humidity": "49"
   }
  }
}

所以我不得不修改我的规则为: SELECT state.reported.* FROM 'dataTopic' 但是当我测试它时,我从Timestream得到了一个错误,看起来是这样的:

 "failures" : [ {
    "failedAction" : "TimestreamAction",
    "failedResource" : "test#sensors",
    "errorMessage" : "Failed to write records to Timestream. The error received was 'Errors at dimensions.0: [Dimension value can not be empty.]'. Message arrived on dataTopic, Action: timestream, Database: test, Table: sensors"

但是,检查主题测试接收的数据时,我没有看到与原始数据的差异

{
  "device" : "abc123",
  "temperature" : "24.50",
  "humidity" : "49"
}

问题可能是什么?到目前为止,我看到相同的数据被接收,但是出于某种原因,Timestream看到的情况不同。我尝试使用Cloudwatch查看Timestream实际接收到的内容,但我无法从这个

profile picture
专家
已提问 5 个月前35 查看次数
1 回答
0

【以下的回答经过翻译处理】 问题的根本原因是无法在替换模板中使用IoT SQL语句的输出。因此,您可以使用SELECT state.reported.*生成Timestream操作的输入,但对于维度值,只能通过${state.reported.device}引用设备。

如果出于某种原因无法使用${state.reported.device}并且需要使用维度${device},最简单的解决方法是使用"Republish"操作将SELECT state.reported.*的内容重新发布到另一个IoT规则中。为了节约成本,您可以使用基本的Ingest将其重新发布到另一个IoT规则,例如使用类似于$aws/rules/MyRule的主题。然而,对于您的用例,我相信上述方法应该可以工作,您无需第二个IoT规则。

profile picture
专家
已回答 5 个月前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则