I am developing an IOT application that is writing to AWS Timestream quite frequently. It is trying to insert the records with different times but still, I am getting the same error. Each record row looks as follows
record = {
'Dimensions': [{'Name': 'id', 'Value': "'123'"},
{'Name': 'kafkaTimestamp', 'Value': "'1657541700943'"}],
'MeasureName': 'Telemetry',
'MeasureValueType': 'MULTI',
'MeasureValues': [
{'Name': 'property', 'Value': 'connection', 'Type': 'VARCHAR'},
{'Name': 'value', 'Value': 'yes', 'Type': 'VARCHAR'}],
'Time': str(int(round(time.time() * 1000)))
}
It has a couple of dimensions which remains the same, but we have different measure values each time.
My understanding is that dimensions, measure name and time make a primary key, so in the code, I am using the latest time every time I am inserting a record into the database but still records are being rejected with the exception.
Name already exists in dimension for the given multi measure name, or name exists in multi measures for the given dimension name
Any thoughts that what could be wrong here with the record schema.
This is a poorly documented constraint in Timestream.
You cannot reuse a multi measure name field that is already registered as a dimension or vice versa. Timestream doesn't allow "column name" reuse between dimensions and MVA fields.
This has been added to the naming limits doc:
https://docs.aws.amazon.com/timestream/latest/developerguide/ts-limits.html#limits.naming