I am using following code to ingest data to DynamoDB.
我使用以下代码将数据提取到DynamoDB。
Code to read from Kinesis
从Kinesis读取的代码
var AWS = require("aws-sdk"),
DOC = require("dynamodb-doc");
docClient = new DOC.DynamoDB();
function upsert(result) {
var info = new Info(result);
console.log('Within upsert :', info.AcctNo);
docClient.putItem({
TableName: "test_lamda_dynamo_table",
Item: info
}, function(err, data) {
if (err) {
console.error('error', err);
context.done('error', err);
} else {
console.log('success', data);
context.done('success', event.Records);
}
});
}
I am not able to see error handler sysouts in cloudwatch logs as well as I am not able to see data in DynamoDB.
我无法在cloudwatch日志中看到错误处理程序sysout,也无法在DynamoDB中看到数据。
Below are sample logs from cloudwatch
以下是来自cloudwatch的示例日志
"Within upsert Info: 1234456"
I am not able to see any error logs related to PutItem function in cloudwatch lambda function logs.
我无法在cloudwatch lambda函数日志中看到任何与PutItem函数相关的错误日志。
Please suggest what I am doing wrong here.
请在这里建议我做错了什么。
1 个解决方案
#1
2
I found solution for this problem on below link.
我在下面的链接找到了解决这个问题的方法。
Querying DynamoDB with Lambda does nothing
使用Lambda查询DynamoDB什么都不做
This was because of context.succeed call used in lambda handler as well.
这是因为lambda处理程序中使用的context.succeed调用也是如此。
exports.handler = function(event, context) {
event.Records.forEach(function(record) {
try {
var payload = new Buffer(record.kinesis.data, 'base64').toString('ascii');
console.log('Decoded payload:', payload);
upsert(payload, context);
// bug
context.succeed("Success")
} catch (e) {
// log error and continue
console.error('Error occured while inserting messages to Dynamo' + e);
}
});
};
#1
2
I found solution for this problem on below link.
我在下面的链接找到了解决这个问题的方法。
Querying DynamoDB with Lambda does nothing
使用Lambda查询DynamoDB什么都不做
This was because of context.succeed call used in lambda handler as well.
这是因为lambda处理程序中使用的context.succeed调用也是如此。
exports.handler = function(event, context) {
event.Records.forEach(function(record) {
try {
var payload = new Buffer(record.kinesis.data, 'base64').toString('ascii');
console.log('Decoded payload:', payload);
upsert(payload, context);
// bug
context.succeed("Success")
} catch (e) {
// log error and continue
console.error('Error occured while inserting messages to Dynamo' + e);
}
});
};