Lesson 2 of 5 Governance, Compliance and Monitoring

Distinguishing CloudWatch, CloudTrail and AWS Config

This lesson explains the three services that give visibility into an account: Amazon CloudWatch monitors performance, AWS CloudTrail records activity and AWS Config records configuration. Telling them apart is a classic exam question.

Learning outcomes

After completing this lesson, you will be able to:

  • Distinguish CloudWatch, CloudTrail and AWS Config by the question each answers.
  • Explain how the three services work together in an investigation.

Comparing the three

CloudWatch, CloudTrail and Config are often confused, but each answers a different question. Amazon CloudWatch answers "how is my system performing?". It collects metrics, such as an EC2 instance's CPU use, stores logs, displays dashboards and raises alarms that send notifications or take automatic action, such as adding servers.

AWS CloudTrail answers "who changed this?". It records the API calls made in an account, through the console, the command line or code, with who made each call, what it did, when and from where. AWS Config answers "what did this look like, and is it compliant?". It records the configuration history of resources and checks them against rules, such as "S3 buckets must not be public". The following table summarises the three services.

ServiceAnswersWhat it does
Amazon CloudWatch"How is my system performing?"Collects metrics (e.g. EC2 CPU), stores logs, shows dashboards, and raises alarms that notify via SNS or act automatically
AWS CloudTrail"Who changed this?"Records API calls: who did what, when and from where, via console, CLI or SDK. Event history keeps 90 days free; trails store logs in S3 long-term
AWS Config"What did this look like, and is it compliant?"Records resource configuration history and evaluates resources against rules, such as "S3 buckets must not be public"
Sort into groups

CloudWatch, CloudTrail or Config?

Exam skills 2.2.5

Decide which service answers each question.

Log in to try this activity Interactive activities are free with an account.

How they work together

Example. An instance was terminated unexpectedly. CloudWatch shows its metrics stopped, CloudTrail shows which user called TerminateInstances, and AWS Config shows the instance's configuration history.

The following diagram shows the question each service answers.

How CloudWatch, CloudTrail and AWS Config work together. Amazon CloudWatch watches performance: metrics, logs and alarms, such as an instance's CPU or a sudden stop. AWS CloudTrail records who did what: every API call, such as which user called TerminateInstances and when. AWS Config records what a resource looked like: its configuration history and whether it complies with rules.
CloudWatch: how it performed; CloudTrail: who did it; Config: what it looked like.
Worked example

Investigating a deleted bucket

On Monday morning, an important S3 bucket has disappeared and the website's images are broken. Each service answers a different part of the investigation:

QuestionServiceAnswer found
When did the website start failing?CloudWatchError rate alarm triggered on Sunday at 22:14
Who deleted the bucket?CloudTrailDeleteBucket called by user "j.smith" at 22:12 from the office IP address
What did the bucket's settings look like before?AWS ConfigConfiguration history shows its policy and versioning settings

To prevent a repeat, the company adds an AWS Config rule to check important buckets, restricts who may delete them with IAM, and enables versioning so deleted objects can be recovered.

Check yourself

Which service raises an alarm when an instance's CPU utilisation is high?

Show answer

Amazon CloudWatch, which collects metrics and triggers alarms.

Exam Tips

Remember for the exam

  • To raise an alarm when CPU is high, use CloudWatch.
  • To find out who terminated an instance or deleted a bucket, use CloudTrail.
  • To track configuration changes and compliance with rules, use AWS Config.
  • To collect and search application logs, use CloudWatch Logs.
  • CloudTrail event history keeps 90 days of events at no charge.