Reputation: 45
I have an AWS Lambda function that is invoked when an instance gets terminated and this the message is stored in Amazon CloudWatch Logs.
I want to extract and filter these log messages to get a particular ID. How can I extract the logs and filter it using Python?
Upvotes: 0
Views: 1607
Reputation: 270144
The easiest method might be to create a rule in Amazon CloudWatch Events that triggers an AWS Lambda function. The function automatically passes information relating to the instance that was terminated. You can write the Lambda function in Python.
This way, your function is automatically triggered whenever an instance is terminated, rather than having to look through logs.
Upvotes: 1