Exam objective 3.2 asks you to design and implement logging and monitoring with CloudWatch. This concept solves the problem of knowing what is happening in your AWS environment at any moment — without you sitting and watching screens all day. For the SCS-C02 exam, understanding CloudWatch Logs, Metrics, and Alarms is essential because security incidents leave traces, and you must know how to capture, measure, and react to those traces.
Jump to a section
A simple way to picture CloudWatch Logs, Metrics, and Alarms for Security
A building security guard monitors an office block. Their job is to watch what happens, record events, and raise alarms when something suspicious occurs. The guard’s notepad is like CloudWatch Logs. Every visitor who signs in, every delivery, every after-hours entry gets written down. These detailed notes help later if someone needs to investigate who entered a restricted floor at 2am.
The guard’s clipboard with running totals — number of people in the building, percentage of rooms currently occupied, average wait time at reception — works like CloudWatch Metrics. These are regular measurements, not raw notes. The guard checks these numbers every hour. If occupancy jumps to 120% of capacity, that is a spike worth noticing.
The guard’s alarm system ties it all together. They mentally set a rule: if more than three unknown visitors enter the CEO’s floor in ten minutes, sound the buzzer. That is a CloudWatch Alarm. The alarm triggers an action: calling the police (like an Amazon Simple Notification Service (SNS) notification to security staff) or locking the stairwell doors (like triggering an AWS Lambda function to block traffic).
The guard doesn’t just watch one floor. They have cameras and sensors across thirty floors. That is CloudWatch Logs, Metrics, and Alarms working across an entire AWS account — multiple services, regions, and accounts all feeding into one system.
Without these three tools working together, the guard is powerless. They cannot see trends, cannot alert in real time, and cannot store evidence for later review. Security relies on all three functions operating continuously.
CloudWatch is a monitoring service from Amazon Web Services (AWS). It collects data from your AWS resources — like virtual servers (Amazon EC2 instances), databases (Amazon RDS), and serverless functions (AWS Lambda). CloudWatch then helps you visualise, analyse, and act on that data. It has three main parts: Logs, Metrics, and Alarms. Each part serves a different purpose but they work together to give you a complete security picture.
CloudWatch Logs are the raw records of events. When something happens inside an AWS resource, it produces a log entry. For example, when someone tries to log into a server and fails, that attempt appears in a log. When an API call is made to delete a storage bucket (Amazon S3 bucket), CloudTrail (a separate service) sends that event to CloudWatch Logs. Logs are text-based, meaning you can read them, search them, and filter them. They are like the security guard’s notebook — every action gets recorded.
Why do logs matter for security? Because attackers leave digital footprints. A brute-force login attack might show hundreds of failed logins in a short period. An unauthorised data download might appear as a large transfer from an unusual IP address. CloudWatch Logs stores these events so you can investigate later. You can also send logs to other AWS services, like Amazon OpenSearch Service, to run complex searches.
CloudWatch Metrics are numerical measurements taken at regular intervals. Instead of reading a text event, you get a number. For example, the CPU utilisation of your EC2 instance might be recorded every minute. The number of HTTP 403 (Forbidden) errors from your web server count is another metric. Metrics are efficient — they take less storage than raw logs and are easy to graph. Think of them as the guard’s clipboard: "At 9am, there were 120 people in the building. At 10am, there were 145 people."
You do not have to create metrics manually. AWS automatically sends many metrics to CloudWatch for its services — these are called standard metrics. CPU utilisation, disk reads, network traffic — all covered. But you can also create custom metrics. For instance, you might send the number of failed login attempts per minute from your application. Custom metrics give you control over exactly what you measure.
CloudWatch Alarms are automated rules that watch a metric and do something when the metric crosses a threshold. For example, you could create an alarm that triggers when CPU utilisation exceeds 80% for five minutes. The alarm can send a notification via SNS (an email or text message to an administrator), or it can trigger an automated response, like launching a new EC2 instance to handle the load (using Auto Scaling). For security, alarms are vital. You might set an alarm when the number of failed SSH login attempts exceeds ten in five minutes. When that happens, the alarm sends a notification to your security team.
Alarms work on three states: OK (all good), ALARM (threshold breached), and INSUFFICIENT_DATA (not enough data to decide). You can also set the number of evaluation periods — meaning the alarm must breach the threshold for multiple consecutive periods before alarming, to avoid false positives from temporary spikes.
CloudWatch Logs, Metrics, and Alarms together create what is called observability. You can see what is happening (logs), measure how much it is happening (metrics), and get notified when something is wrong (alarms). This replaces the old method of manually checking servers or relying on users to report problems. It is automated, scalable, and centralised.
For the SCS-C02 exam, you also need to know about CloudWatch Logs Insights. This is a query language that lets you search and analyse logs in real time. For instance, you could run a query to find all log entries from the last hour that contain the words "UnauthorizedOperation". That helps you rapidly identify security events without reading every log line.
CloudWatch also integrates with AWS CloudTrail, which records API activity in your account. CloudTrail logs can be sent to CloudWatch Logs, giving you both resource-level events (from CloudTrail) and system-level events (from your operating systems and applications) in one place.
One important distinction: CloudWatch is for monitoring what is happening now and recently. It is not a long-term archive by default. Logs can be stored for a configurable retention period (from 1 day to forever). For cost reasons, you might keep recent logs in CloudWatch for quick access and move older logs to Amazon S3 (cheaper long-term storage) or Amazon Glacier (even cheaper archival storage). This is called log lifecycle management.
Finally, consider permissions. Not everyone in your organisation should be able to view logs or create alarms. AWS Identity and Access Management (IAM) lets you control who can read logs, who can create alarms, and who can delete them. This is critical for security — you do not want an attacker to be able to see your security logs or disable your alarms.
Install and configure the CloudWatch agent on an EC2 instance
This step installs software on the virtual server that collects operating system logs (like /var/log/secure) and custom metrics (like memory usage). Without the agent, CloudWatch only receives basic metrics (like CPU utilisation) and no OS logs. For security monitoring, you need OS logs to see login attempts, sudo commands, and system errors.
Create a CloudWatch Logs log group and specify a retention policy
A log group is a container for logs from a specific source (e.g., all logs from your web servers). You decide how many days to keep these logs (e.g., 30 days for daily monitoring, 365 days for compliance). The retention policy automatically deletes logs older than the chosen period, saving costs. Without retention, logs are stored indefinitely, which can be expensive.
Create a metric filter on the log group for a security pattern
Define a filter pattern, such as 'Failed password' or 'ERROR', that CloudWatch will look for in every incoming log event. For example, a filter pattern "Failed password for invalid user" creates a metric named FailedSSHCount. This metric increments every time the pattern appears. Metric filters are the bridge between logs (text) and metrics (numbers).
Create a CloudWatch Alarm on the custom metric
Set a threshold on the metric (e.g., alarm if FailedSSHCount > 5 in 5 minutes). Choose an evaluation period (e.g., 2 out of 2 datapoints must be above threshold). Then configure the alarm action: send a notification to an SNS topic (which can email a security team) or trigger a Lambda function to automatically block the attacking IP. The alarm is the automated watchman.
Monitor and refine the alarm and log retention
After the alarm is active, review false positives. Maybe a legitimate user mistyped a password five times in two minutes — that is not an attack. Adjust the threshold or evaluation periods accordingly. Also, periodically check log storage costs and retention. If you need logs for more than the CloudWatch retention period, set up an export to S3 using a lifecycle policy or a scheduled Lambda function.
Imagine you work as a security engineer for an e-commerce company that runs its website on AWS. This website handles customer orders, payment details, and personal data. You must ensure that if an attack happens, you can detect it quickly and respond.
Every day, you start by checking CloudWatch dashboards. These are customisable views that show your most important metrics at a glance. You look at a dashboard showing the number of HTTP 500 (server error) responses from your web servers. If that number suddenly jumps, it might mean an attacker is trying to exploit a vulnerability. You also look at a metric tracking the number of unique IP addresses connecting to your database — a sudden increase could indicate a data scraping attempt.
At 10:15am, you receive an email from a CloudWatch Alarm. The alarm is named "SSH-Brute-Force". It triggered because the metric "FailedSSHAttempts" exceeded 20 in five minutes. You open the CloudWatch Logs console and search for log entries from the specific EC2 instance that reported the high number. Using CloudWatch Logs Insights, you run a query:
fields @timestamp, @message | filter @message like /Failed password/ | sort @timestamp desc | limit 50
This shows you the exact times of each failed login attempt, the usernames attempted, and the source IP addresses. You see dozens of attempts from an IP address in a country where your company has no customers. That looks like a brute-force attack. You then escalate: you block that IP address using an AWS Network Firewall rule and notify your security team.
After handling the incident, you refine your monitoring. You notice the alarm only looked at one EC2 instance, but you have ten instances. An attacker might spread login attempts across multiple instances to avoid triggering any single alarm. So you create a new custom metric that aggregates all failed SSH attempts across all instances — a global count. You set an alarm on that aggregate metric with a lower threshold, because the distributed attack might otherwise go undetected.
Later, you audit your CloudWatch Logs retention policy. You currently keep logs for 30 days. For security investigations, you often need logs from more than six months ago. You create a lifecycle policy to automatically export logs older than 30 days to an S3 bucket. In S3, you can store them for years at low cost. You also enable S3 server access logging and CloudTrail logging to that same bucket, so all evidence is in one place.
Finally, you review IAM permissions. You discover that a junior developer accidentally deleted an important log group yesterday because their IAM role had too broad permissions. You change the policy so that only senior engineers can delete log groups, while developers can only read and query logs. This prevents accidental or malicious deletion of evidence.
Throughout this entire process, CloudWatch Metrics, Logs, and Alarms work in sync. Metrics gave you the big picture numbers. Logs provided the detailed evidence. Alarms woke you up when something needed immediate attention. Without these three tools, you would be blind to attacks and unable to prove what happened during an incident.
The SCS-C02 exam tests CloudWatch Logs, Metrics, and Alarms in several ways. You will see scenario-based questions where you must decide which combination of services and settings solves a security monitoring requirement. The exam loves testing subtle differences between similar concepts. Here is what you need to master. - CloudWatch vs CloudTrail: This is the number one confusion area. CloudTrail records API calls made in your AWS account (e.g., "who created an EC2 instance?"). CloudWatch Logs records events from apps and OS (e.g., "a login attempt failed on the EC2 instance"). Exam questions often describe a security event and then ask which service captured it. If the event is an AWS API call (like "DeleteBucket"), the answer is CloudTrail (which can then send logs to CloudWatch Logs). If the event happens inside an operating system or application (like "sudo command executed"), the answer is CloudWatch Logs with a CloudWatch agent installed on the instance. - Metric Filter vs Alarm: A metric filter is a pattern used to extract a metric from a log stream. For example, you create a metric filter that counts log entries containing "ERROR". That produces a metric called "ErrorCount". The alarm then watches that metric and triggers when it crosses a threshold. A common exam trap: they ask "how do you alarm when a specific word appears in logs?" The answer is: create a metric filter, then an alarm on that metric. The alarm alone does not look at logs — it only looks at metrics. The metric filter bridges logs to metrics. - Standard Metrics vs Custom Metrics: Standard metrics come free (for most services) and are automatically collected (e.g., EC2 CPUUtilization). Custom metrics cost extra and require you to publish data using the AWS CLI, SDK, or PutMetricData API. Exam questions ask when to use custom metrics — answer: when you need to monitor something AWS does not automatically measure, like application-specific counters (e.g., number of user logins, number of API calls that failed validation). - Alarm States and Periods: The exam tests that an alarm has three states: OK, ALARM, INSUFFICIENT_DATA. It also tests that you can set the number of evaluation periods. If you set "3 out of 3 datapoints" to trigger, the alarm is more sensitive to sustained issues. If you set "2 out of 3", it responds faster but may false-alarm more. A trap: they describe a scenario where a service has a brief spike in CPU every 5 minutes, and ask which alarm configuration avoids false alarms. The answer is to increase the number of evaluation periods or extend the period length. - Encryption: CloudWatch Logs supports encryption at rest using AWS Key Management Service (KMS). You can enable KMS encryption on a log group. The exam tests that you cannot encrypt log groups using the AWS Management Console after creation — you must use the AWS CLI or SDK. They also test that CloudWatch Metrics cannot be encrypted at rest (they are numerical and have no encryption option). - Log Retention and Export: You must know how to set log retention (in days). Exam questions ask: "How do you keep logs for compliance but reduce costs?" Answer: set a retention policy that moves logs to S3 after X days, then delete from CloudWatch. Another trap: CloudWatch Logs does not automatically export to S3 — you must create an export task (which can be manual or automated via Lambda). The exam expects you to know the difference between simple retention (delete after X days) and export to S3 (copy then optionally delete). - Cross-Account Monitoring: The exam tests that you can send logs from multiple accounts to a central monitoring account using CloudWatch Logs cross-account subscription. This is important for security teams managing many accounts. A typical question: "How do you centralise logs from 50 AWS accounts?" The answer: create a subscription filter in each account that sends logs to a single destination in the monitoring account (using Kinesis Data Firehose or Lambda). - Real-Time vs Batch: CloudWatch Logs and Metrics are near real-time (typically within seconds). CloudTrail delivers logs every 5 minutes by default (or more frequently with Insights). The exam likes to ask about the latency difference for security incident response. - The exact concepts you must memorise: The three states of an alarm. The difference between CloudWatch Logs, Metrics, and Alarms. How metric filters work. The purpose of CloudWatch Logs Insights. How to encrypt log groups. How to set retention. The default metric names for EC2 (CPUUtilization, DiskReadOps, etc.). That CloudWatch cannot replace CloudTrail or vice versa.
CloudWatch Logs store raw event records from AWS resources, operating systems, and applications, but require explicit configuration to receive logs from most services.
CloudWatch Metrics are numerical measurements taken at regular intervals, and they are the only data type that CloudWatch Alarms can monitor.
To alarm on a specific log pattern, you must create a metric filter that extracts a metric from the log stream, then create an alarm on that metric.
CloudWatch Alarms have three states: OK, ALARM, and INSUFFICIENT_DATA, and you can configure evaluation periods to reduce false positives.
CloudWatch Logs encryption at rest requires you to enable AWS KMS encryption on each log group, and it cannot be done through the console after creation.
Log retention in CloudWatch is not infinite by default; you must set a retention period and optionally export logs to Amazon S3 for long-term, cost-effective storage.
CloudTrail records AWS API activity, while CloudWatch Logs records resource-level events — they are complementary, not interchangeable.
Cross-account log aggregation requires subscription filters and a central destination account using Kinesis Data Firehose or Lambda.
These come up on the exam all the time. Here's how to tell them apart.
CloudWatch Logs
Stores raw, unstructured text events such as error messages, login attempts, and application logs.
Retention is user-defined per log group (1 day to forever), and costs are based on data ingested and stored.
Can be queried using CloudWatch Logs Insights for complex searches and pattern matching.
Requires a metric filter to be converted into a metric for alarm monitoring.
CloudWatch Metrics
Stores numerical data at regular intervals, like CPU utilisation percentages or request counts.
Retention is automatic: 15 months for standard metrics, with granularity decreasing over time.
Displayed on dashboards and used directly by alarms — no conversion needed.
Cannot store text or log messages; only numbers and dimensions.
CloudWatch Alarm
Monitors a single metric and changes state (OK, ALARM, INSUFFICIENT_DATA) based on a threshold.
Only triggers actions when the state changes or remains in a state for a configurable period.
Must be manually linked to an SNS topic or Auto Scaling policy to perform an action.
Amazon Simple Notification Service
A messaging service that can send notifications via email, SMS, HTTP, or Lambda.
Can receive messages from multiple CloudWatch Alarms, CloudTrail, or other AWS services.
Is not a monitoring service — it only handles delivery of messages.
Standard Metric
Automatically collected by AWS for most services (e.g., EC2 CPUUtilization).
Free to use (included in CloudWatch free tier).
Cannot be modified or deleted by the user.
Custom Metric
Manually published by the user using AWS CLI, SDK, or CloudWatch agent.
Incur additional costs per metric per month.
Completely user-defined: you choose the name, value, unit, and dimensions.
Mistake
CloudWatch Logs automatically captures all logs from every AWS service without any setup.
Correct
Most services do not send logs to CloudWatch Logs by default. You must either configure the service to send logs (e.g., EC2 requires a CloudWatch agent installed) or use CloudTrail to deliver API logs to CloudWatch. Some services like Lambda automatically send logs if you configure a log group.
Beginners assume AWS is 'all connected'. In reality, you must explicitly enable log delivery. This misconception causes people to miss important events during an exam scenario.
Mistake
CloudWatch Alarms can directly monitor log entries to trigger notifications.
Correct
Alarms can only monitor metrics, not raw logs. To alarm on a specific log pattern, you must first create a metric filter on that log group, which generates a metric. Then you create an alarm on that metric.
The name 'CloudWatch Logs' suggests logs are the primary data, but alarms only speak to metrics. People mix up the layers because they see both logs and alarms in the same console.
Mistake
If an alarm triggers, it automatically fixes the problem.
Correct
An alarm itself does nothing except change state. You must configure an action (e.g., send to SNS which triggers a Lambda function to restart a server or block an IP). The alarm is just the trigger, not the fix.
People familiar with smart home alarms might think 'alarm = automated response'. AWS requires explicit configuration of actions. The exam tests that you know how to link alarms to SNS or Auto Scaling.
Mistake
CloudWatch Metrics are stored forever by default.
Correct
CloudWatch Metrics have a default retention period: 15 months for standard metrics, but custom metrics older than 14 days are stored at 1-minute granularity for only that period, then 5-minute granularity for 15 months. There is no 'forever' default. You must export to S3 for long-term archival.
Beginners think cloud storage is infinite and free. The exam tests cost awareness and retention practices.
Mistake
CloudWatch Logs encryption is automatic and always on.
Correct
By default, CloudWatch Logs is not encrypted at rest. You must explicitly enable KMS encryption on each log group. This is a common exam scenario where you are asked to enable encryption for compliance (e.g., PCI DSS).
Many people assume AWS encrypts everything by default (which is true for some services like S3, but not for CloudWatch Logs). This assumption leads to incorrect answers in security compliance questions.
Reveal each answer, then mark whether you got it right. Score 60%+ to unlock the next chapter.
Yes, but indirectly. The alarm sends a message to an SNS topic. You configure SNS to send an SMS text message to your phone, or an email to your inbox. The alarm itself only triggers the SNS notification.
CloudTrail records all API calls made in your AWS account, like 'who created a user' or 'when was an S3 bucket deleted'. CloudWatch monitors the performance and health of your resources, like CPU usage and log events. For security, you often send CloudTrail logs to CloudWatch for central analysis.
No, by default CloudWatch only collects basic metrics like CPU utilisation, disk reads/writes, and network traffic. To monitor memory (RAM) or disk space, you need to install the CloudWatch agent on the instance and configure it to report those custom metrics.
Yes. You can export logs from CloudWatch to Amazon S3 (cheaper storage) using an export task. Once exported and verified, you can delete the logs from CloudWatch. You can automate this with a lifecycle policy or a Lambda function running on a schedule.
Most likely because you have not created a metric filter on that log group. Alarms only monitor metrics, not raw logs. Check that a metric filter exists for the pattern you care about, that the filter is associated with the correct log group, and that the alarm is monitoring that specific metric.
No. CloudWatch Logs does not encrypt data at rest by default. You must enable AWS KMS encryption on each log group. Data in transit is encrypted using TLS. For security compliance (e.g., HIPAA, PCI DSS), you almost always need to enable KMS encryption.
You've finished CloudWatch Logs, Metrics, and Alarms for Security. Continue through the SCS-C02 study guide to build a complete picture of the exam.
Done with this chapter?