Filter CloudWatch Logs to extract Instance ID

喜夏-厌秋 提交于 2019-12-23 05:29:16

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/44548888/filter-cloudwatch-logs-to-extract-instance-id

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!