From b617170554f6739c9538f2574272087d7b49b9ee Mon Sep 17 00:00:00 2001 From: himanshu219 Date: Thu, 4 Feb 2021 12:20:13 +0530 Subject: [PATCH] added check for ignoring null messages --- cloudwatchlogs-with-dlq/cloudwatchlogs_lambda.js | 5 ++++- cloudwatchlogs/cloudwatchlogs_lambda.js | 12 ++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/cloudwatchlogs-with-dlq/cloudwatchlogs_lambda.js b/cloudwatchlogs-with-dlq/cloudwatchlogs_lambda.js index 1f3c6d4..ec5a6ac 100644 --- a/cloudwatchlogs-with-dlq/cloudwatchlogs_lambda.js +++ b/cloudwatchlogs-with-dlq/cloudwatchlogs_lambda.js @@ -83,7 +83,10 @@ function createRecords(config, events, awslogsData) { log.logStream = awslogsData.logStream; log.logGroup = awslogsData.logGroup; } - records.push(log); + if (log.message) { + // ignoring null & undefined messages + records.push(log); + } }); return records; } diff --git a/cloudwatchlogs/cloudwatchlogs_lambda.js b/cloudwatchlogs/cloudwatchlogs_lambda.js index 4ff600b..734cfe4 100644 --- a/cloudwatchlogs/cloudwatchlogs_lambda.js +++ b/cloudwatchlogs/cloudwatchlogs_lambda.js @@ -216,11 +216,15 @@ exports.handler = function (event, context, callback) { var metadataKey = sumoMetaKey(awslogsData, log.message); - if (metadataKey in messageList) { - messageList[metadataKey].push(log); - } else { - messageList[metadataKey] = [log]; + if (log.message) { + // ignoring null & undefined messages + if (metadataKey in messageList) { + messageList[metadataKey].push(log); + } else { + messageList[metadataKey] = [log]; + } } + }); // Push messages to Sumo