Monitoring using CloudWatch
First, we will introduce a few key concepts in CloudWatch: logs, metrics, alarms, and dashboards. CloudWatch persists ingested data in the form of logs or metrics organized by timestamps. As the name suggests, logs refer to text data emitted throughout the lifetime of a program. On the other hand, metrics represent organized numeric data such as CPU or memory utilization. Since metrics are stored in an organized matter, CloudWatch supports aggregating metrics and creating histograms from collected data. An alarm can be set up to alert if unusual changes are reported for the target metric. Also, a dashboard can be set up to get an intuitive view of selected metrics and raised alarms.
In the following example, we will describe how to log metric data using a CloudWatch service client from the boto3
library. The metric data is structured as a dictionary and consists of metric names, dimensions, and values. The idea of dimensions is to capture factual information...