QuestionQ335

Data Operations and Support

A data engineer created an Amazon Athena table named cloudtrail_logs to query AWS CloudTrail logs and prepare data for audits. The data engineer must write a query that displays errors with error codes occurring since the start of 2024. The query must return the 10 most recent errors.

Which query satisfies these requirements?

  • A select count (*) as TotalEvents, eventname, errorcode, errormessage from cloudtrail_logswhere errorcode is not nulland eventtime >= '2024-01-01T00:00:00Z' group by eventname, errorcode, errormessageorder by TotalEvents desclimit 10;
  • B select count (*) as TotalEvents, eventname, errorcode, errormessage from cloudtrail_logs where eventtime >= '2024-01-01T00:00:00Z' group by eventname, errorcode, errormessage order by TotalEvents desc limit 10;
  • C select count (*) as TotalEvents, eventname, errorcode, errormessage from cloudtrail_logswhere eventtime >= '2024-01-01T00:00:00Z' group by eventname, errorcode, errormessageorder by eventname asc limit 10;
  • D select count (*) as TotalEvents, eventname, errorcode, errormessage from cloudtrail_logs where errorcode is not nulland eventtime >= '2024-01-01T00:00:00Z' group by eventname, errorcode, errormessagelimit 10;
Explanation

Displaying errors with error codes requires filtering on errorcode IS NOT NULL in addition to the 2024 date filter; only this option and one other apply that filter, and this one is the sole choice among those that also includes an ORDER BY clause to sort the aggregated results before limiting to 10 rows. Options that omit the errorcode filter would include successful (non-error) events, and the option without an ORDER BY clause returns an arbitrary, unsorted set of rows.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!