PacketAI's CloudWatch collector (lambda function for AWS) sends logs to PacketAI for automated anomaly detection. Here is the code for the lambda function:
If you have an existing Lambda function associated with the log group to be set up, you must go to AWS CloudWatch page and delete the existing subscription filter, otherwise you will get this error message: “An error occurred when creating the trigger: The log group host-log already has an enabled subscription filter associated with it.”
If you do not have an existing role with Lambda execution permission, you should got to AWS IAM service to create a role for running Lambda functions.
Installation
Create a new lambda function with the code above
To create a new Lambda function
Select “Author from scratch”
Provide the following base information:
Function Name: packetai-cloudwatch
Runtime: Node.js.18.x
Click on “Create function”
Click on Designer and click on “Add a trigger”. Type “CloudWatch Logs” and choose your log group.