amazon-timestream

Timestream client does not accept TIMESTAMP as Measure value type


I have a simple payload that I would like to write into Timestream using AWS Lambda. For some reason it gets rejected with the following error if I try to add a TIMESTAMP type measure value:

ERROR   RejectedRecords:  ValidationException: Invalid value 2022-10-03 06:55:38.175000000 for timestamp measure value type.
at Request.extractError (/var/runtime/node_modules/aws-sdk/lib/protocol/json.js:52:27)
at Request.callListeners (/var/runtime/node_modules/aws-sdk/lib/sequential_executor.js:106:20)
at Request.emit (/var/runtime/node_modules/aws-sdk/lib/sequential_executor.js:78:10)
at Request.emit (/var/runtime/node_modules/aws-sdk/lib/request.js:686:14)
at Request.transition (/var/runtime/node_modules/aws-sdk/lib/request.js:22:10)
at AcceptorStateMachine.runTo (/var/runtime/node_modules/aws-sdk/lib/state_machine.js:14:12)
at /var/runtime/node_modules/aws-sdk/lib/state_machine.js:26:10
at Request.<anonymous> (/var/runtime/node_modules/aws-sdk/lib/request.js:38:9)
at Request.<anonymous> (/var/runtime/node_modules/aws-sdk/lib/request.js:688:12)
at Request.callListeners (/var/runtime/node_modules/aws-sdk/lib/sequential_executor.js:116:18) 

Here is the payload itself:

{
    "DatabaseName": "mydbname",
    "TableName": "mytable",
    "Records": [{
        "MeasureName": "m",
        "MeasureValueType": "MULTI",
        "Time": "1665042286800",
        "Dimensions": [{
            "Name": "d",
            "Value": "v"
        }],
        "MeasureValues": [{
                "Name": "EventName",
                "Value": "PhotoTaken",
                "Type": "VARCHAR"
            },
            {
                "Name": "EventDate",
                "Value": "2022-10-03 06:55:38.175000000",
                "Type": "TIMESTAMP"
            }
        ]
    }]
}

Here is the javascript code that writes it (pretty standard)

let writeClient = new AWS.TimestreamWrite({ region: "us-west-2" });
const params = {
  DatabaseName: databaseName,
  TableName: tableName,
  Records: records
};
return writeClient.writeRecords(params)

Not sure if it has anything to do with my data retention settings, but in case it does, I set it to 1 hour for Memory Store retention and 1 day for Magnetic Store retention (this is all test stuff at this point, so I don't need to keep for too long)


Solution

  • Can you try converting the timestamp value from a Date string to milliseconds, similar as you see on the time attribute? e.g.:

    "Value": "1664780157030"
    

    instead of

    "Value": "2022-10-03 06:55:38.175000000"