Search code examples
amazon-web-servicesamazon-cloudwatchamazon-cloudwatchlogsaws-cloudwatch-log-insights

Removing specific log events from CloudWatchLogs


I looked through the documentation of CloudWatch Logs, but I could not find any method to manually remove partial data from a log stream.

The only way to remove data is to:

  • Remove the log stream, but that will remove all data (not just the data we want to remove)
  • Set the retention policy to a smaller time window, so that the log events older than X time will be deleted. This also removes more than we'd like to remove.

Does anyone have experience with removing specific log records?


Solution

  • The comment of user ronald8192 is indeed the reality:

    Unfortunately, as of today, you cannot delete a single log event from CloudWatch log stream, the alternative will be using Lambda functions: set a Lambda function trigger, filter all logs, then write the remaining logs to a new log group/stream, then delete the original log stream.