我已经阅读了很多关于向 firehose 添加换行符的类似问题,但它们都围绕着将换行符添加到源代码中。问题是我无权访问源,第三方正在将数据传输到我们的 Kinesis 实例,我无法将 '\n' 添加到源。
我尝试使用以下代码进行流水数据转换:
'use strict';
console.log('Loading function');
exports.handler = (event, context, callback) => {
/* Process the list of records and transform them */
const output = [];
event.records.forEach((record) => {
const results = {
/* This transformation is the "identity" transformation, the data is left intact */
recordId: record.recordId,
result: record.data.event_type === 'alert' ? 'Dropped' : 'Ok',
data: record.data + '\n'
};
output.push(results);
});
console.log(`Processing completed. Successful records ${output.length}.`);
callback(null, { records: output }); …Run Code Online (Sandbox Code Playgroud)