Skip to main content

AWS DVA-C02 Drill: DynamoDB Streams & Lambda Logging - Unique Customer Metrics Dashboard

Jeff Taakey
Author
Jeff Taakey
21+ Year Enterprise Architect | AWS SAA/SAP & Multi-Cloud Expert.

Jeff’s Note
#

Unlike generic exam dumps, ADH analyzes this scenario through the lens of a Real-World Lead Developer.

For DVA-C02 candidates, the confusion often lies in knowing the best method to track and aggregate Lambda-processed data efficiently with minimal operational overhead. In production, this is about leveraging CloudWatch Logs Insights for real-time querying of dynamic Lambda log data rather than building complex ETL pipelines. Let’s drill down.

The Certification Drill (Simulated Question)
#

Scenario
#

A mid-sized e-commerce startup called NovaTrade uses Amazon DynamoDB to maintain orders placed by customers. Their frontend application inserts orders into a DynamoDB table, which has DynamoDB Streams enabled to capture data changes in real time. An AWS Lambda function consumes these stream events to process and log order data. During an internal audit, the dev team found that some incoming orders had the order quantity mistakenly set to zero, which should never happen. The lead developer has been tasked with creating a daily dashboard to display how many unique customers are affected by this issue each day to help with debugging and business insight.

The Requirement:
#

Implement a solution that lets the developer create a dashboard showing the count of unique customers ordering zero-quantity items aggregated by day.

The Options
#

  • A) Grant the Lambda function’s execution role permissions to upload logs to Amazon CloudWatch Logs. Implement a CloudWatch Logs Insights query that selects the number of unique customers for orders with order quantity equal to 0 and groups the results in 1-day periods. Add the CloudWatch Logs Insights query to a CloudWatch dashboard.

  • B) Use Amazon Athena to query AWS CloudTrail API logs for API calls. Implement an Athena query that selects the number of unique customers for orders with order quantity equal to 0 and groups the results in 1-day periods. Add the Athena query to an Amazon CloudWatch dashboard.

  • C) Configure the Lambda function to send events to Amazon EventBridge. Create an EventBridge rule that groups the number of unique customers for orders with order quantity equal to 0 in 1-day periods. Add a CloudWatch dashboard as the target of the rule.

  • D) Turn on custom Amazon CloudWatch metrics for the DynamoDB stream of the DynamoDB table. Create a CloudWatch alarm that groups the number of unique customers for orders with order quantity equal to 0 in 1-day periods. Add the CloudWatch alarm to a CloudWatch dashboard.


Google adsense
#

leave a comment:

Correct Answer
#

A

Quick Insight: The Developer Imperative
#

Lambda functions automatically push logs to CloudWatch Logs, which can then be queried in real-time using Logs Insights for ad-hoc aggregation like counting unique customers.

This approach avoids complex ETL or querying CloudTrail (which suffers from latency and incomplete context) and leverages native integration for rapid operational metrics.

Content Locked: The Expert Analysis
#

You’ve identified the answer. But do you know the implementation details that separate a Junior from a Senior?


The Expert’s Analysis
#

Correct Answer
#

Option A

The Winning Logic
#

In this case, the Lambda function already processes the DynamoDB stream events and logs order details, including the problematic order quantity. Granting the Lambda execution role permission to write these logs to CloudWatch Logs is standard, as it enables storing operational data. Using CloudWatch Logs Insights, the developer can write a query that extracts logs with order quantity zero, counts unique customer IDs, and aggregates the count by day. This approach is straightforward, real-time, cost-effective, and uses native AWS services designed for these metrics and ad-hoc analysis.

  • Key points:
    • Lambda logs are real-time and push to CloudWatch Logs automatically.
    • CloudWatch Logs Insights supports complex queries and aggregation (e.g., count distinct).
    • Adding the query to a CloudWatch dashboard provides a seamless visualization layer.
    • No complex ETL pipelines or external querying is required.

The Trap (Distractor Analysis):
#

  • Why not B?
    CloudTrail logs record API calls but won’t capture the internal order data and order quantity details directly. Also, CloudTrail data latency and volume make Athena querying inefficient for the detailed application-level data needed.

  • Why not C?
    Using EventBridge rules to aggregate counts is not viable directly, as EventBridge doesn’t provide native grouping or aggregation of events over time. It is event-driven, but collecting and rolling up counts is typically done downstream, adding complexity.

  • Why not D?
    CloudWatch custom metrics for a DynamoDB stream would require additional instrumentation and do not natively provide unique customer counts or grouping by order quantity with granularity. Alarms trigger on threshold conditions but are not suited for metric aggregation dashboards capturing “unique” counts.


The Technical Blueprint
#

B) For Developer (Code Snippet: CloudWatch Logs Insights Query Example)
#

fields @timestamp, @message
| filter orderQuantity = 0
| stats distinct_count(customerId) as uniqueCustomers by bin(1d, @timestamp)
| sort @timestamp desc

IAM policy snippet to grant Lambda write permissions to CloudWatch Logs:

{
    "Effect": "Allow",
    "Action": [
        "logs:CreateLogGroup",
        "logs:CreateLogStream",
        "logs:PutLogEvents"
    ],
    "Resource": "arn:aws:logs:*:*:*"
}

The Comparative Analysis (Developer)
#

Option API Complexity Performance Use Case
A Low - straightforward Logs Insights query on Lambda logs High - near real-time query on latest logs Best for quick dashboards based on Lambda-processed data
B Medium - querying CloudTrail data with Athena Low - CloudTrail lag and large data scanned Not suitable to analyze application data like order details
C High - EventBridge rules do not provide aggregation, require external processing Medium - event-driven, but needs downstream aggregation Complex and indirect solution
D High - custom metrics require instrumentation Medium - alarms trigger but no unique count aggregation Not suitable for unique counts or detailed analytics

Real-World Application (Practitioner Insight)
#

Exam Rule
#

“For the AWS Developer exam, always pick CloudWatch Logs Insights when you need to analyze Lambda application logs quickly and build dynamic dashboards.”

Real World
#

“In production, developers often struggle with delayed or incomplete metrics from CloudTrail or EventBridge and rely on native Lambda logging combined with Logs Insights for fast, scalable insights.”


(CTA) Stop Guessing, Start Mastering
#


Disclaimer

This is a study note based on simulated scenarios for the AWS DVA-C02 exam.

The DevPro Network: Mission and Founder

A 21-Year Tech Leadership Journey

Jeff Taakey has driven complex systems for over two decades, serving in pivotal roles as an Architect, Technical Director, and startup Co-founder/CTO.

He holds both an MBA degree and a Computer Science Master's degree from an English-speaking university in Hong Kong. His expertise is further backed by multiple international certifications including TOGAF, PMP, ITIL, and AWS SAA.

His experience spans diverse sectors and includes leading large, multidisciplinary teams (up to 86 people). He has also served as a Development Team Lead while cooperating with global teams spanning North America, Europe, and Asia-Pacific. He has spearheaded the design of an industry cloud platform. This work was often conducted within global Fortune 500 environments like IBM, Citi and Panasonic.

Following a recent Master’s degree from an English-speaking university in Hong Kong, he launched this platform to share advanced, practical technical knowledge with the global developer community.


About This Site: AWS.CertDevPro.com


AWS.CertDevPro.com focuses exclusively on mastering the Amazon Web Services ecosystem. We transform raw practice questions into strategic Decision Matrices. Led by Jeff Taakey (MBA & 21-year veteran of IBM/Citi), we provide the exclusive SAA and SAP Master Packs designed to move your cloud expertise from certification-ready to project-ready.