amazon-web-servicesaws-iotaws-iot-analytics

AWS IOT analytics json format error in Analytics pipeline


Can i send same Key value in JSON to AWS IOT Analytics pipeline? Does anyone have idea how to solve this? here is my JSON:

{ "data": [ { "sensor": { "value": 100.1 }, "ts": 1401000 }, { "sensor": { "value": 120.5 }, "ts": 1401154 }, { "slave2": { "point1": 50 }, "ts": 1401250 }, { "slave2": { "point2": false }, "ts": 140350 }, { "current_sensor": 10, "ts": 150400 }, { "water_level": 50, "ts": 1504450 }, { "switch": true, "ts": 154030 } ] }


Solution

  • I'm not quite sure what you mean by sending the same key value - have you been able to send the data fragment above to IoT Analytics OK? If not, did you get an error in your Cloudwatch logs - note that you may need to enable logging in Console->Settings if you have not already done this.

    If you don't get an error sending, are you having problems getting the data back out? Again if you could perhaps show the SQL query you are using and what the results are, that might be helpful.

    All that said, you can of course re-shape your data using activities in the pipeline. For example you could;

    1. Create a lambda activity with a lambda function to extract the individual messages and send exactly what you need to the datastore.

    2. Create Attribute Adder/Remover activities to reformat the message.

    The reference documentation has examples of using Lambda to re-shape messages and also information on adding and removing attributes to re-shape messages.