Amazon CloudWatch metric alarm allows customers to watch a metric value, or a math expression value for the metric, and trigger actions when the value breaks a certain threshold limit. These alarms can be used to trigger notifications delivered via Amazon SNS, email, SMS, etc. It has been a requirement for customers to include the application log messages in the alarm notification message, so it becomes easier for operational staff to identify the root cause for the alarm notification. In this article, I will demonstrate how to embed the application log messages in the notification email body when the CloudWatch alarm is activated.
Terraform installed and ready to use.
HashiCorp Terraform: v0.13 or later
Python: v3.9 or later
Node.js: 14.x or later
The following architecture diagram shows the components involved in this solution and the interaction between them.