CloudWatch

Published on
Reading time
2 min read

Overview

Monitoring services can be accomplished by tracking metrics with CloudWatch. In CloudWatch, you can create alerts relating to whatever is being tracked. Services will send and update any of these custom metrics to CloudWatch which will issue an alert when those metrics reach configured thresholds. Common things to track would be things that relate to spending or overutilization in order to prevent unnecessary spending. When an alert is triggered, an automated action can be performed to correct the issue like turning off an unused EC2 instance when someone forgets to do so. Additionally, it can monitor for performance of services like the computational performance of a function in Lambda.

One of the most common pairings for CloudWatch is to issue account holders notifications via SNS when usage hits certain levels. For example, if reads or writes are too high, a CloudWatch alert can be triggered to issue a notification letting people know that usage may be higher than planned. This is especially important for development of things like Lambda functions where an infinite loops could unnoticeably run up a huge bill - potentially tens of thousands of dollars in minutes if left unchecked!

Dashboard

Along with alerts and actions, metrics can be organized into a dashboard for an overview of how services are tracking over time. Note that metric data is only held for 15 months before being deleted.

Anomaly Detection

Another optional feature is anomaly detection which is a Machine Learning-powered service for analyzing metrics for extreme deviations. If traffic spikes unexpectedly, that would be a sign of an anomaly and can be configured to trigger an alarm. This can help detect any unwanted spikes in behavior that could be caused by something breaking or an attacker.

Logs

For development, its common to include logs in Lambda functions to keep a record of the invocations and track if anything breaks or doesn't behave as expected. In AWS, these logs are sent to CloudWatch automatically and can be viewed there. Logs are sent to the configured CloudWatch Log Group for a given function or group of functions. Furthermore, logs from other places like containers, EC2 instances, or Amplify apps can be sent to CloudWatch.