AWS Builder Center
Monitoring & Threat Detection in AWS: How CloudTrail, CloudWatch and GuardDuty Work Together

Monitoring & Threat Detection in AWS: How CloudTrail, CloudWatch and GuardDuty Work Together

Learn how AWS CloudTrail, Amazon CloudWatch, and Amazon GuardDuty help organizations monitor cloud activity, detect suspicious behavior, and respond to potential security threats. This beginner-friendly guide explores their individual roles, how they complement each other, and how to build a stronger security monitoring strategy on AWS.

Monitoring & Threat Detection in AWS: How CloudTrail, CloudWatch and GuardDuty Work Together
Introduction
In cloud computing, deploying applications and managing infrastructure is only half the job. The other half is ensuring that everything running in your environment remains secure.
Imagine an unusual login attempt occurs in your AWS account. Someone accesses an AWS resource from an unfamiliar location, modifies a security configuration, or makes API calls that don't match normal activity.
How would you know this happened?
How would you investigate it?
And more importantly, how would you identify whether it represents a genuine security threat?
AWS provides several services that help answer these questions. Three particularly important services are:
- AWS CloudTrail: Records activity and API events in your AWS account. - Amazon CloudWatch: Monitors resources, applications, logs, and operational metrics. - Amazon GuardDuty: Uses threat intelligence and machine learning to identify potentially malicious activity.
Although these services have different responsibilities, they can complement each other to provide better visibility and security monitoring.
Let's understand how.
1. AWS CloudTrail: Knowing What Happened
AWS CloudTrail is a service that records activity within your AWS account.
Whenever someone or something performs an API operation, such as creating an S3 bucket, launching an EC2 instance, or modifying an IAM policy, CloudTrail can record information about that activity.
These records are called events.
A CloudTrail event can contain information such as:
- Who performed the action. - What API operation was performed. - When the operation occurred. - Which AWS resource was involved. - The source IP address of the request. - Whether the operation was successful or unsuccessful.
Why is CloudTrail important?
Imagine an IAM user suddenly receives administrator permissions.
Without proper logging, identifying who made the change and when it happened could become difficult.
CloudTrail helps security teams investigate such situations by providing a record of account activity.
Important CloudTrail concepts
Management events: Record management operations performed on AWS resources, such as creating, updating, or deleting resources.
Data events: Provide visibility into data-plane operations, such as accessing objects in an S3 bucket or invoking certain Lambda functions. These may require additional configuration and can incur charges.
Event history: Provides a searchable history of management events for the previous 90 days in a Region.
Trails: Allow you to deliver ongoing event records to destinations such as Amazon S3, with optional integrations for further analysis.
CloudTrail is especially useful for auditing, compliance, troubleshooting, and security investigations.
2. Amazon CloudWatch: Knowing What Is Happening
While CloudTrail helps answer what actions occurred in your AWS account, Amazon CloudWatch focuses on monitoring operational activity and application health.
CloudWatch collects and monitors metrics, logs, and events from AWS resources and supported applications.
For example, suppose you are running an application on an EC2 instance.
You may want to monitor:
- CPU utilization. - Network activity. - Disk-related metrics. - Application logs. - Error rates. - Application performance.
CloudWatch helps you collect this information and create alarms when specific conditions are met.
Important CloudWatch components
Metrics: Numerical measurements that help monitor resource performance, such as CPU utilization.
Logs: Allow you to collect, store, and analyze log data from applications and supported AWS services.
Alarms: Monitor metrics and trigger actions when configured thresholds or conditions are reached.
Dashboards: Provide a visual overview of important metrics and monitoring information.
Practical example
Imagine your EC2 instance normally operates at 30% CPU utilization.
Suddenly, CPU utilization increases to 95% and remains high.
You can configure a CloudWatch alarm to detect this condition and send a notification through Amazon SNS.
This allows administrators to investigate the issue before it significantly affects application availability.
CloudWatch is therefore useful for both operational monitoring and supporting security investigations.
3. Amazon GuardDuty: Identifying Potential Threats
Monitoring activity is important, but manually reviewing every event can be difficult, especially in large cloud environments.
This is where Amazon GuardDuty becomes valuable.
Amazon GuardDuty is a managed threat detection service that continuously analyzes supported data sources and uses threat intelligence and machine learning to identify potentially malicious activity.
It helps detect suspicious behavior without requiring security teams to manually inspect every individual event.
What can GuardDuty detect?
Depending on the enabled protection plans and supported data sources, GuardDuty can identify suspicious activities such as:
- Unusual API activity. - Potentially compromised AWS credentials. - Communication with known malicious IP addresses or domains. - Suspicious network behavior. - Potential threats involving supported workloads and services.
Understanding GuardDuty findings
When GuardDuty identifies potentially suspicious activity, it generates a finding.
A finding generally contains information such as:
- Finding type. - Severity. - Affected AWS resource. - Time of detection. - Details about the suspicious activity.
Security teams can investigate these findings and decide whether further action is necessary.
It is important to remember that a finding is an indication of potential malicious activity, not automatic proof of a successful attack.
4. How Do These Three Services Work Together?
Now let's understand the most interesting part: how CloudTrail, CloudWatch, and GuardDuty complement one another.
Consider a scenario where an attacker obtains compromised AWS credentials.
The attacker attempts to access AWS resources and performs suspicious API operations.
Here's how the services can help:
Step 1: CloudTrail records the activity
CloudTrail records relevant API activity, including information about the identity, operation, and source of the request.
Step 2: GuardDuty analyzes supported activity
GuardDuty analyzes supported data sources and looks for suspicious patterns. If it identifies potentially malicious behavior, it generates a security finding.
Step 3: CloudWatch supports monitoring
CloudWatch can collect relevant application and service logs and monitor operational metrics. Configured alarms and notifications can help teams identify abnormal conditions.
Step 4: Security teams investigate
The security team reviews the GuardDuty finding, examines relevant CloudTrail events, checks available logs, and determines whether the activity requires a response.
Step 5: Appropriate action is taken
Depending on the investigation, the team may restrict access, rotate compromised credentials, isolate affected resources, or take other containment measures.
This workflow demonstrates how different AWS services can contribute to a stronger security monitoring strategy.
5. A Real-World Example: Detecting Suspicious IAM Activity
Let's take another example.
Suppose an AWS account normally operates from a particular environment, but suddenly an IAM identity performs unusual API operations from an unfamiliar IP address.
A possible investigation could look like this:
1. CloudTrail helps identify the API calls made by the identity. 2. GuardDuty may generate a finding if the activity matches a suspicious pattern. 3. CloudWatch can help examine relevant logs and operational signals. 4. The security administrator investigates the identity, affected resources, and timeline. 5. If credentials are compromised, the team follows its incident response procedure to contain the threat.
The important point is that no single service provides the complete picture in every situation.
Combining activity records, monitoring information, and threat detection can make investigations more effective.
6. Best Practices for AWS Security Monitoring
If you are building or managing an AWS environment, here are some practices worth following.
1. Enable appropriate CloudTrail logging
Configure trails according to your auditing and security requirements. Consider the management and data events that your environment needs to capture.
2. Monitor important resources
Use CloudWatch metrics, logs, and alarms to understand the health and behavior of your infrastructure.
3. Enable Amazon GuardDuty
Evaluate GuardDuty for your AWS accounts and Regions. Review its findings regularly rather than simply enabling the service and ignoring alerts.
4. Centralize security visibility
For multi-account environments, consider using AWS Organizations and appropriate centralized logging and security management approaches.
5. Investigate findings instead of ignoring them
Not every finding represents a confirmed attack, but every relevant finding should be evaluated according to its severity and context.
6. Prepare an incident response process
Define how your team will investigate, contain, and recover from security incidents before an actual incident occurs.
7. How Beginners Can Practise These Services
The best way to understand cloud security is to combine theoretical knowledge with hands-on practice.
Here is a simple learning sequence:
Exercise 1: Explore CloudTrail
- Open the AWS Management Console. - Navigate to CloudTrail. - Explore Event history. - Perform a test operation in your AWS account. - Check whether the operation appears in the event history.
Exercise 2: Explore CloudWatch
- Open Amazon CloudWatch. - Explore available EC2 metrics if you have a test instance. - Create a simple dashboard. - Learn how metric alarms work.
Exercise 3: Explore GuardDuty
- Open Amazon GuardDuty. - Understand how the service is enabled. - Explore its finding types and severity levels. - Study sample findings using AWS-provided documentation or supported sample-finding functionality.
Always check service pricing before enabling features or creating resources, and clean up unnecessary resources after your lab.
Conclusion
Cloud security is not just about preventing unauthorized access. It is also about understanding what happens inside your environment, identifying suspicious activity, and responding appropriately.
AWS CloudTrail provides visibility into account activity.
Amazon CloudWatch helps monitor infrastructure, applications, and logs.
Amazon GuardDuty helps identify potentially malicious activity through managed threat detection.
Together, these services provide important building blocks for monitoring and protecting AWS environments.
For anyone interested in becoming a Cloud Security Engineer, understanding these services is a valuable step toward learning security monitoring, threat detection, auditing, and incident response.
The cloud is constantly changing, and security monitoring should never be treated as a one-time task.
My question to the AWS community: If you were building a security monitoring setup for a new AWS environment, which service would you configure first: CloudTrail, CloudWatch, or GuardDuty? And why?
I'd love to hear different approaches and learn from experienced AWS builders.
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article