External Monitoring#
With an EC2 instance running, we get some monitoring data automatically and at no extra charge.
There are certain things that a running instance must communicate to the hardware/system that hosts it. AWS needs to track this information “from the outside” in order to manage its infrastructure. For example:
- How much CPU is the instance using?
- How much network bandwidth is it taking up?
- How much data is it reading from and/or writing to disk?
All these things can be monitored externally by AWS, and they package it into a service called CloudWatch Metrics. The metrics allow us to answer questions like:
- Is my server doing anything? (If not, you’ll see idle CPU usage.)
- Is my server overloaded? (Watch for sustained high CPU usage.)
- Is my server consuming too much bandwidth? (Watch network usage.)
These are a great start, and for some services they’re all you need.
Assignment#
Cost check: Basic CloudWatch metrics for EC2 (CPU, network, disk) are included at no extra charge. CloudWatch dashboards have a small monthly cost, so delete your test dashboard when you clean up resources.
Create a dashboard for patientping-web-v2, force CPU usage high, verify the spike, then stop the load.
- In the AWS Console, go to “CloudWatch” → “Dashboards” and click “Create dashboard.”
- Name the dashboard
patientping-dashboardand click “Create dashboard.” - Add a line widget for
patientping-web-v2CPU:- Choose “Line” when prompted for widget type.
- In metric namespaces, select “EC2” → “Per-Instance Metrics.”
- Search for your instance ID, and select the row where the metric is
CPUUtilization, then check it. - Click “Create widget.”
- Set the dashboard timeframe to “15 minutes”.
- Click “Save dashboard.”
- SSH into
patientping-web-v2and start CPU load:
yes > /dev/null- Keep the load running for at least 5 minutes so the dashboard shows a clear CPU spike!
- Once you’re satisfied that your monitoring is working, stop the load by pressing Ctrl+C in the terminal where you ran the
yescommand.