Course menuDVA-C03

Exams / DVA-C03 / Logging and CloudWatch Logs Insights / Question 2

DVA-C03 practice question: Logging and CloudWatch Logs Insights (2 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.

Last verified against current AWS documentation ·How we write our questions

A Python Lambda function uses the runtime's standard logger, and its plain-text output includes many DEBUG messages.

In production the team pays for every DEBUG line stored in CloudWatch Logs. The team must stop DEBUG lines from being sent to CloudWatch Logs without changing the function code, and each log entry should carry a level field that can be queried in Logs Insights.

What should the developer configure?

Choose one answer.

  1. A. A metric filter on the log group that drops any line containing DEBUG.
  2. B. Keep the text log format, and set the application log level to INFO.
  3. C. A subscription filter that forwards the log group to Amazon OpenSearch Service for parsing.
  4. D. Set the log format to JSON and the application log level to INFO.
Show the answer and explanation

Answer: D

  • A. Wrong: A metric filter turns matching log lines into metric data, but the lines have already been ingested into the log group. It cannot stop DEBUG lines being sent to CloudWatch Logs.
  • B. Wrong: Log-level filtering needs the JSON log format. With plain text, the application log level setting does not filter the output, so DEBUG lines still reach CloudWatch Logs.
  • C. Wrong: A subscription filter copies log events to another service after they are in CloudWatch Logs, which adds cost. It does not stop DEBUG lines from being ingested.
  • D. Right: Correct. JSON format gives each entry a level field. With an application log level of INFO, Lambda sends INFO and higher levels to CloudWatch Logs and filters out DEBUG, which also reduces volume. No function code change is needed for this runtime. Learn more: Configuring advanced logging controls for Lambda functions (opens in a new tab)

Explanation

Lambda's advanced logging controls can filter application logs by level before they reach CloudWatch Logs, but log-level filtering requires the JSON log format. Metric filters and subscription filters act on logs after they are ingested, so they do not reduce what is stored.

Study

Keep practicing

Answer questions with a score at the end, or practice just this topic with the explanation after each one. No sign-up needed.

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