Using CloudWatch Logs Subscription Filter for Real-Time Alerts
A company is using Amazon CloudWatch Logs to monitor application logs from EC2 instances. The operations team wants to receive a notification when a specific error pattern appears in the logs. Which solution requires the least operational overhead?
Quick Answer
The answer is to use a CloudWatch Logs subscription filter to invoke a Lambda function that publishes to an SNS topic. This solution has the least operational overhead because it eliminates the need to create and manage metric filters and CloudWatch alarms, instead enabling real-time, event-driven processing directly from the log stream. When the CloudWatch agent streams logs to CloudWatch Logs, the subscription filter evaluates each log event against the specified error pattern and triggers the Lambda function instantly upon a match, which then sends the notification via SNS. On the AWS Certified SysOps Administrator Associate SOA-C02 exam, this scenario tests your understanding of event-driven log monitoring versus polling-based approaches; a common trap is choosing metric filters with alarms, which add latency and require threshold management. For a memory tip, remember “Filter → Function → Fan-out” — the subscription filter triggers the Lambda, which fans out the alert through SNS, keeping the pipeline lean and real-time.
⚠ Common exam trap
Candidates often overcomplicate the solution by introducing Lambda functions (Option C) because they think serverless is always simpler. However, native CloudWatch features (metric filter + alarm) provide a fully managed, no-code solution that requires fewer components to manage, making it the least overhead.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
Install the CloudWatch agent on EC2 instances and configure it to stream logs to CloudWatch Logs. Create a metric filter for the error pattern and set a CloudWatch alarm that sends an SNS notification.
It uses native CloudWatch capabilities: the CloudWatch agent streams logs to CloudWatch Logs, a metric filter extracts the error pattern, and a CloudWatch alarm directly sends an SNS notification. This approach requires no additional compute resources like Lambda and no custom code, resulting in the least operational overhead. Option C requires creating and managing a Lambda function, which adds complexity and maintenance. Options B and D are more complex with extra services.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
Install the CloudWatch agent on EC2 instances and configure it to stream logs to CloudWatch Logs. Create a metric filter for the error pattern and set a CloudWatch alarm that sends an SNS notification.
Why this is correct
The CloudWatch agent streams logs to CloudWatch Logs, where a metric filter converts the error pattern into a metric that triggers an alarm and SNS notification. This is fully managed, requiring no custom code or polling infrastructure.
- ✗
Use Amazon Kinesis Data Firehose to stream all logs to Amazon S3, then run an AWS Glue job to search for the error pattern and trigger an SNS notification.
Why it's wrong here
Firehose, Glue and S3 add a multi-service pipeline with job scheduling and storage management, far exceeding the requirement. A CloudWatch Logs metric filter with an alarm action to SNS detects the pattern directly from the log group, which is the low-overhead approach.
- ✗
Install the CloudWatch agent on EC2 instances, stream logs to CloudWatch Logs, and use a subscription filter to invoke an AWS Lambda function that publishes a message to an SNS topic.
Why it's wrong here
A subscription filter invoking Lambda requires deploying and maintaining function code plus IAM roles, adding operational overhead; CloudWatch Logs metric filters with alarms notify directly without custom compute. Lambda suits complex enrichment or routing beyond simple pattern alerting.
- ✗
Configure the application to write logs to a file, use the CloudWatch agent to send logs to CloudWatch Logs, set a metric filter, and use the filter to send data to Amazon EventBridge, which then triggers a Lambda function to send an SNS notification.
Why it's wrong here
The CloudWatch agent, metric filter, EventBridge rule and Lambda function form a multi-component pipeline requiring maintenance of each resource. A metric filter alarm with a direct SNS action publishes the notification without any compute or event-routing infrastructure, which is the least operational overhead.
Quick reference
Cloud Service Model Comparison
| Model | You Manage | Provider Manages | Examples |
|---|---|---|---|
| IaaS | OS, runtime, apps, data | Hardware, hypervisor, networking | EC2, Azure VMs, GCP Compute Engine |
| PaaS | Apps and data | OS, runtime, middleware, hardware | Elastic Beanstalk, Azure App Service |
| SaaS | Data and settings only | Everything else | Microsoft 365, Salesforce, Workday |
| FaaS / Serverless | Function code only | Infra, scaling, runtime | Lambda, Azure Functions, Cloud Run |
| CaaS | Containers and apps | Kubernetes, OS, hardware | EKS, AKS, GKE |
Go deeper
Related to this question
About these practice questions
One of 1,169 original SOA-C02 practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →
Same concept, more angles
1 more way this is tested on SOA-C02
These questions test the same concept from different angles. Work through them to make sure you can recognise it however the exam phrases it.
Variation 1. A company uses Amazon CloudWatch Logs to store application logs. The security team needs to be alerted when any log group contains a specific error pattern. The solution must minimize latency and operational overhead. What should a SysOps administrator do?
medium- A.Stream the logs to Amazon Kinesis Data Firehose, which then triggers a Lambda function to check for errors.
- B.Create a CloudWatch metric filter on the log group and set an alarm that triggers an SNS notification.
- ✓ C.Create a Lambda function subscribed to the CloudWatch Logs log group, which checks for the error pattern and publishes to an SNS topic.
- D.Use CloudWatch Logs Insights to run a query every minute and send results via SNS.
Why C: Subscribing a Lambda function directly to a CloudWatch Logs log group allows real-time, low-latency processing of log events as they arrive. The Lambda function can parse each log event for the specific error pattern and publish to an SNS topic to alert the security team, minimizing operational overhead by avoiding additional streaming or polling services.
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This SOA-C02 practice question is part of Courseiva's free Amazon Web Services certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the SOA-C02 exam.