DVA-C03 practice question: Logging and CloudWatch Logs Insights (3 of 3)
Troubleshooting and Optimization A free question from our original DVA-C03 practice exam. Try it, then open the answer to see why each option is right or wrong.
A checkout team's Lambda function writes plain-text logs to Amazon CloudWatch Logs. A developer is testing a fix, and a tester will repeat the failing checkout several times while the developer watches for errors.
The developer needs to see matching log lines appear as they are written. The results do not need to be saved, and the log group also holds many unrelated lines that would fill the screen.
Which approach meets these requirements?
Choose one answer.
AA. Run a Logs Insights query over the last 5 minutes each time the tester repeats the checkout, and read the results from the query output.
BB. Open Live Tail on the function's log group, and filter the live stream to lines that contain ERROR.
CC. Create an export task that copies the log group to Amazon S3, and download the exported files after the tester finishes.
DD. Add a subscription filter that sends every log event to a second Lambda function, which writes the errors to its own log group.
Show the answer and explanation
Answer: B
A. Wrong: A Logs Insights query returns results for a time range when you run it, so each new line needs another run. It does not show lines as they arrive.
B. Right: Correct. Live Tail streams new log events from the selected log group in near real time, and a filter pattern such as ERROR narrows the stream to matching lines. It needs no saved results or query, which fits a live test run. Learn more: Troubleshoot with CloudWatch Logs Live Tail (opens in a new tab)
C. Wrong: Export tasks run asynchronously and deliver files to S3 in batches, so the developer would wait a long time for the results. The task does not show errors while the test runs.
D. Wrong: This builds a processing pipeline that the test does not need. It adds another function to maintain and more log groups to read, rather than showing the lines to the developer now.
Explanation
Live Tail is the CloudWatch Logs feature for watching log events as they are written, with a filter pattern to narrow the stream. Logs Insights queries and exports work on a time range after the fact, and a subscription filter forwards events to another service. None of those shows the developer matching lines during a live test.
Want more on Logging and CloudWatch Logs Insights? The 5 full-length practice sets have 11 more Logging and CloudWatch Logs Insights questions, 390 in all, none of them in the free exam. One payment of $14.99, no subscription. See the practice sets →