Course menuDVA-C02

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

DVA-C02 practice question: Logging and CloudWatch Logs Insights (2 of 2)

Troubleshooting and Optimization A free question from our original DVA-C02 practice exam. Try it, then open the answer to see why each option is right or wrong.

A team writes plain-text log lines from its Lambda functions and finds it hard to filter them by log level in CloudWatch Logs Insights. They also want to stop DEBUG messages reaching CloudWatch Logs in production without changing the function code. What should the developer configure?

Choose one answer.

  1. A. A metric filter on the log group that drops lines containing DEBUG.
  2. B. A subscription filter that sends the logs to Amazon OpenSearch Service for parsing.
  3. C. A shorter retention period on the log group so DEBUG messages expire sooner.
  4. D. The function's logging configuration with log format JSON and an application log level of INFO.
Show the answer and explanation

Answer: D

  • A. Wrong: Metric filters turn matching log events into metrics. They do not drop or restructure log events.
  • B. Wrong: This adds infrastructure and does not stop DEBUG messages being written to CloudWatch Logs.
  • C. Wrong: Retention deletes all old events whatever their level, and DEBUG messages are still ingested first.
  • D. Right: Correct. JSON logs have named fields such as level that Logs Insights discovers, and log-level filtering drops DEBUG output at the source.

Explanation

Lambda's advanced logging controls let you choose JSON or text log format and set application and system log levels. JSON output gives each entry named fields that are easy to query, and log-level filtering stops lower-level entries being sent to CloudWatch Logs, which also cuts volume. Structured logging is a key part of observability.

Study

Keep practising

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