IOT Core - DynamoDB rule is executed successfully but data is not present in the table

0

Hi Experts,

Followed the latest documentation from this URL: https://docs.aws.amazon.com/iot/latest/developerguide/iot-ddb-rule.html, to create a rule to insert the received IOT data into DynamoDB. I am using the IOT test client to publish the MQTT data. Find the latest cloud watch logs generated for my last run. I did create a IAM Role with the sufficient privileges to allow the rule action to execute on behalf of me as per the documentation. Could you through some light on this issue?

timestamp,message 1664986813614,"{""timestamp"":""2022-10-05 16:20:13.614"",""logLevel"":""INFO"",""traceId"":""3dcaa2fc-7d2f-8d68-f150-2301ba85ac2a"",""accountId"":""406825964493"",""status"":""Success"",""eventType"":""Subscribe"",""protocol"":""MQTT"",""topicName"":""device/+/data"",""clientId"":""iotconsole-a4040030-a732-4e0e-a234-5277b8bb852f"",""principalId"":""406825964493"",""sourceIp"":""122.162.62.41"",""sourcePort"":65047}" 1664986842003,"{""timestamp"":""2022-10-05 16:20:42.003"",""logLevel"":""INFO"",""traceId"":""be0b67f4-a8dc-4be8-3e13-c361c264ed6b"",""accountId"":""406825964493"",""status"":""Success"",""eventType"":""RuleExecution"",""clientId"":""iotconsole-a4040030-a732-4e0e-a234-5277b8bb852f"",""topicName"":""device/9/data"",""ruleName"":""wx_data_ddb"",""ruleAction"":""DynamoAction"",""resources"":{""ItemRangeKeyValue"":""9"",""IsPayloadJSON"":""true"",""ItemHashKeyField"":""sample_time"",""Operation"":""Insert"",""ItemRangeKeyField"":""device_id"",""Table"":""wx_data_1"",""ItemHashKeyValue"":""1664986841918""},""principalId"":""406825964493""}" 1664987544715,"{""timestamp"":""2022-10-05 16:32:24.715"",""logLevel"":""INFO"",""traceId"":""317c9fee-3f3c-2cee-ccc1-b8d7247a4b4a"",""accountId"":""406825964493"",""status"":""Success"",""eventType"":""Disconnect"",""protocol"":""MQTT"",""clientId"":""iotconsole-a4040030-a732-4e0e-a234-5277b8bb852f"",""principalId"":""406825964493"",""sourceIp"":""122.162.62.41"",""sourcePort"":65047,""disconnectReason"":""MQTT_KEEP_ALIVE_TIMEOUT""}"

Find the earlier runs related cloud watch logs as well below for your information.

I am attaching the cloud watch logs as well, rule is executed successfully, but not find the data in the Database. Pasting the cloud watch logs for your information below. @timestamp,@message 2022-10-05 16:32:24.715,"{""timestamp"":""2022-10-05 16:32:24.715"",""logLevel"":""INFO"",""traceId"":""317c9fee-3f3c-2cee-ccc1-b8d7247a4b4a"",""accountId"":""406825964493"",""status"":""Success"",""eventType"":""Disconnect"",""protocol"":""MQTT"",""clientId"":""iotconsole-a4040030-a732-4e0e-a234-5277b8bb852f"",""principalId"":""406825964493"",""sourceIp"":""122.162.62.41"",""sourcePort"":65047,""disconnectReason"":""MQTT_KEEP_ALIVE_TIMEOUT""}" 2022-10-05 16:20:42.003,"{""timestamp"":""2022-10-05 16:20:42.003"",""logLevel"":""INFO"",""traceId"":""be0b67f4-a8dc-4be8-3e13-c361c264ed6b"",""accountId"":""406825964493"",""status"":""Success"",""eventType"":""RuleExecution"",""clientId"":""iotconsole-a4040030-a732-4e0e-a234-5277b8bb852f"",""topicName"":""device/9/data"",""ruleName"":""wx_data_ddb"",""ruleAction"":""DynamoAction"",""resources"":{""ItemRangeKeyValue"":""9"",""IsPayloadJSON"":""true"",""ItemHashKeyField"":""sample_time"",""Operation"":""Insert"",""ItemRangeKeyField"":""device_id"",""Table"":""wx_data_1"",""ItemHashKeyValue"":""1664986841918""},""principalId"":""406825964493""}" 2022-10-05 16:20:41.952,"{""timestamp"":""2022-10-05 16:20:41.952"",""logLevel"":""INFO"",""traceId"":""be0b67f4-a8dc-4be8-3e13-c361c264ed6b"",""accountId"":""406825964493"",""status"":""Success"",""eventType"":""RuleMatch"",""clientId"":""iotconsole-a4040030-a732-4e0e-a234-5277b8bb852f"",""topicName"":""device/9/data"",""ruleName"":""wx_data_ddb"",""principalId"":""406825964493""}" 2022-10-05 16:20:41.952,"{""timestamp"":""2022-10-05 16:20:41.952"",""logLevel"":""DEBUG"",""traceId"":""be0b67f4-a8dc-4be8-3e13-c361c264ed6b"",""accountId"":""406825964493"",""status"":""Success"",""eventType"":""StartingRuleExecution"",""clientId"":""iotconsole-a4040030-a732-4e0e-a234-5277b8bb852f"",""topicName"":""device/9/data"",""ruleName"":""wx_data_ddb"",""ruleAction"":""DynamoAction"",""principalId"":""406825964493""}" 2022-10-05 16:20:41.921,"{""timestamp"":""2022-10-05 16:20:41.921"",""logLevel"":""INFO"",""traceId"":""be0b67f4-a8dc-4be8-3e13-c361c264ed6b"",""accountId"":""406825964493"",""status"":""Success"",""eventType"":""Publish-In"",""protocol"":""MQTT"",""topicName"":""device/9/data"",""clientId"":""iotconsole-a4040030-a732-4e0e-a234-5277b8bb852f"",""principalId"":""406825964493"",""sourceIp"":""122.162.62.41"",""sourcePort"":65047}" 2022-10-05 16:20:41.917,"{""timestamp"":""2022-10-05 16:20:41.917"",""logLevel"":""INFO"",""traceId"":""de1383c6-4551-8b90-948f-8d7b26641db5"",""accountId"":""406825964493"",""status"":""Success"",""eventType"":""Publish-Out"",""protocol"":""MQTT"",""topicName"":""device/9/data"",""clientId"":""iotconsole-a4040030-a732-4e0e-a234-5277b8bb852f"",""principalId"":""406825964493"",""sourceIp"":""122.162.62.41"",""sourcePort"":65047}" 2022-10-05 16:20:41.281,"{""timestamp"":""2022-10-05 16:20:41.281"",""logLevel"":""INFO"",""traceId"":""6da17ec1-5786-d2e7-7a49-3ec7a4b77076"",""accountId"":""406825964493"",""status"":""Success"",""eventType"":""RuleExecution"",""clientId"":""iotconsole-a4040030-a732-4e0e-a234-5277b8bb852f"",""topicName"":""device/9/data"",""ruleName"":""wx_data_ddb"",""ruleAction"":""DynamoAction"",""resources"":{""ItemRangeKeyValue"":""9"",""IsPayloadJSON"":""true"",""ItemHashKeyField"":""sample_time"",""Operation"":""Insert"",""ItemRangeKeyField"":""device_id"",""Table"":""wx_data_1"",""ItemHashKeyValue"":""1664986841195""},""principalId"":""406825964493""}" 2022-10-05 16:20:41.230,"{""timestamp"":""2022-10-05 16:20:41.230"",""logLevel"":""DEBUG"",""traceId"":""6da17ec1-5786-d2e7-7a49-3ec7a4b77076"",""accountId"":""406825964493"",""status"":""Success"",""eventType"":""StartingRuleExecution"",""clientId"":""iotconsole-a4040030-a732-4e0e-a234-5277b8bb852f"",""topicName"":""device/9/data"",""ruleName"":""wx_data_ddb"",""ruleAction"":""DynamoAction"",""principalId"":""406825964493""}" 2022-10-05 16:20:41.230,"{""timestamp"":""2022-10-05 16:20:41.230"",""logLevel"":""INFO"",""traceId"":""6da17ec1-5786-d2e7-7a49-3ec7a4b77076"",""accountId"":""406825964493"",""status"":""Success"",""eventType"":""RuleMatch"",""clientId"":""iotconsole-a4040030-a732-4e0e-a234-5277b8bb852f"",""topicName"":""device/9/data"",""ruleName"":""wx_data_ddb"",""principalId"":""406825964493""}" 2022-10-05 16:20:41.200,"{""timestamp"":""2022-10-05 16:20:41.200"",""logLevel"":""INFO"",""traceId"":""6da17ec1-5786-d2e7-7a49-3ec7a4b77076"",""accountId"":""406825964493"",""status"":""Success"",""eventType"":""Publish-In"",""protocol"":""MQTT"",""topicName"":""device/9/data"",""clientId"":""iotconsole-a4040030-a732-4e0e-a234-5277b8bb852f"",""principalId"":""406825964493"",""sourceIp"":""122.162.62.41"",""sourcePort"":65047}" 2022-10-05 16:20:41.188,"{""timestamp"":""2022-10-05 16:20:41.188"",""logLevel"":""INFO"",""traceId"":""abf5eb8c-c852-a31a-4850-b55d234c208c"",""accountId"":""406825964493"",""status"":""Success"",""eventType"":""Publish-Out"",""protocol"":""MQTT"",""topicName"":""device/9/data"",""clientId"":""iotconsole-a4040030-a732-4e0e-a234-5277b8bb852f"",""principalId"":""406825964493"",""sourceIp"":""122.162.62.41"",""sourcePort"":65047}" 2022-10-05 16:20:37.360,"{""timestamp"":""2022-10-05 16:20:37.360"",""logLevel"":""INFO"",""traceId"":""445a948f-290c-c378-f9b6-bd3147de9fa9"",""accountId"":""406825964493"",""status"":""Success"",""eventType"":""RuleExecution"",""clientId"":""iotconsole-a4040030-a732-4e0e-a234-5277b8bb852f"",""topicName"":""device/9/data"",""ruleName"":""wx_data_ddb"",""ruleAction"":""DynamoAction"",""resources"":{""ItemRangeKeyValue"":""9"",""IsPayloadJSON"":""true"",""ItemHashKeyField"":""sample_time"",""Operation"":""Insert"",""ItemRangeKeyField"":""device_id"",""Table"":""wx_data_1"",""ItemHashKeyValue"":""1664986837260""},""principalId"":""406825964493""}" 2022-10-05 16:20:37.293,"{""timestamp"":""2022-10-05 16:20:37.293"",""logLevel"":""INFO"",""traceId"":""445a948f-290c-c378-f9b6-bd3147de9fa9"",""accountId"":""406825964493"",""status"":""Success"",""eventType"":""RuleMatch"",""clientId"":""iotconsole-a4040030-a732-4e0e-a234-5277b8bb852f"",""topicName"":""device/9/data"",""ruleName"":""wx_data_ddb"",""principalId"":""406825964493""}" 2022-10-05 16:20:37.293,"{""timestamp"":""2022-10-05 16:20:37.293"",""logLevel"":""DEBUG"",""traceId"":""445a948f-290c-c378-f9b6-bd3147de9fa9"",""accountId"":""406825964493"",""status"":""Success"",""eventType"":""StartingRuleExecution"",""clientId"":""iotconsole-a4040030-a732-4e0e-a234-5277b8bb852f"",""topicName"":""device/9/data"",""ruleName"":""wx_data_ddb"",""ruleAction"":""DynamoAction"",""principalId"":""406825964493""}" 2022-10-05 16:20:37.263,"{""timestamp"":""2022-10-05 16:20:37.263"",""logLevel"":""INFO"",""traceId"":""445a948f-290c-c378-f9b6-bd3147de9fa9"",""accountId"":""406825964493"",""status"":""Success"",""eventType"":""Publish-In"",""protocol"":""MQTT"",""topicName"":""device/9/data"",""clientId"":""iotconsole-a4040030-a732-4e0e-a234-5277b8bb852f"",""principalId"":""406825964493"",""sourceIp"":""122.162.62.41"",""sourcePort"":65047}" 2022-10-05 16:20:37.253,"{""timestamp"":""2022-10-05 16:20:37.253"",""logLevel"":""INFO"",""traceId"":""4d2bd3fa-0830-0b41-a51c-68d868134cbb"",""accountId"":""406825964493"",""status"":""Success"",""eventType"":""Publish-Out"",""protocol"":""MQTT"",""topicName"":""device/9/data"",""clientId"":""iotconsole-a4040030-a732-4e0e-a234-5277b8bb852f"",""principalId"":""406825964493"",""sourceIp"":""122.162.62.41"",""sourcePort"":65047}"

asked 2 years ago363 views
2 Answers
0

Have you followed "You don't see your data in the DynamoDB table" under "Troubleshooting your DynamoDB rule"?

https://docs.aws.amazon.com/iot/latest/developerguide/iot-ddb-rule.html#iot-ddb-rule-test

profile pictureAWS
EXPERT
Greg_B
answered 2 years ago
  • Yes, i have seen the content of this section "You don't see your data in the DynamoDB table", following is the exception observed in the rule execution. { "timestamp": "2022-10-06 15:40:05.198", "logLevel": "ERROR", "traceId": "618898da-ddbb-7c2d-8b0a-21e4a345a077", "accountId": "406825964493", "status": "Failure", "eventType": "RuleExecution", "clientId": "iotconsole-cf1f7655-8553-4d23-82d8-52027498d4e3", "topicName": "device/10/data", "ruleName": "wx_data_ddb", "ruleAction": "DynamoAction", "resources": { "ItemRangeKeyValue": "10", "IsPayloadJSON": "true", "ItemHashKeyField": "sample_time", "Operation": "Insert", "ItemRangeKeyField": "device_id", "Table": "wx_data", "ItemHashKeyValue": "1665070805104" }, "principalId": "406825964493", "details": "One or more parameter values were invalid: Type mismatch for key device_data expected: N actual: M (Service: AmazonDynamoDBv2; Status Code: 400; Error Code: ValidationException; Request ID: 3UTK3RFC7E7ATQFACD73LCNMK3VV4KQNSO5AEMVJF66Q9ASUAAJG; Proxy: null)" }

    I could not make out the root cause from this error text. This is the framed rule ${cast(topic(2) AS DECIMAL)} for the device_id. It is suppose to take the number 33 or 10 from the below publishing topic's listed.

    device/10/data device/33/data { "temperature": 28, "humidity": 80, "barometer": 1013, "wind": { "velocity": 22, "bearing": 255 } }

  • Hi. It's complaining about device_data not device_id. I suspect you may have previously put some items into the table by mistake, where device_data was just a number (type N) instead of a Map (type M). And now you've got the Rule correct, it's trying to put a map, but the type is already a number. So it fails. I suggest you delete the table, and re-create it. Then re-try.

    Before deleting, I suggest you navigate to DynamoDB->Tables->wx_data->Explore table items to examine what's already in the table.

0

Yes, i have seen the content of this section "You don't see your data in the DynamoDB table", following is the exception observed in the rule execution. { "timestamp": "2022-10-06 15:40:05.198", "logLevel": "ERROR", "traceId": "618898da-ddbb-7c2d-8b0a-21e4a345a077", "accountId": "406825964493", "status": "Failure", "eventType": "RuleExecution", "clientId": "iotconsole-cf1f7655-8553-4d23-82d8-52027498d4e3", "topicName": "device/10/data", "ruleName": "wx_data_ddb", "ruleAction": "DynamoAction", "resources": { "ItemRangeKeyValue": "10", "IsPayloadJSON": "true", "ItemHashKeyField": "sample_time", "Operation": "Insert", "ItemRangeKeyField": "device_id", "Table": "wx_data", "ItemHashKeyValue": "1665070805104" }, "principalId": "406825964493", "details": "One or more parameter values were invalid: Type mismatch for key device_data expected: N actual: M (Service: AmazonDynamoDBv2; Status Code: 400; Error Code: ValidationException; Request ID: 3UTK3RFC7E7ATQFACD73LCNMK3VV4KQNSO5AEMVJF66Q9ASUAAJG; Proxy: null)" }

I could not make out the root cause from this error text. This is the framed rule ${cast(topic(2) AS DECIMAL)} for the device_id. It is suppose to take the number 33 or 10 from the below publishing topic's listed.

device/10/data device/33/data { "temperature": 28, "humidity": 80, "barometer": 1013, "wind": { "velocity": 22, "bearing": 255 } }

answered 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions