Sapto Banerjee
Sapto Banerjee

Reputation: 45

Filter CloudWatch Logs to extract Instance ID

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

Answers (1)

John Rotenstein
John Rotenstein

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.

Amazon CloudWatch Events

This way, your function is automatically triggered whenever an instance is terminated, rather than having to look through logs.

Upvotes: 1

Related Questions