Troubleshooting and Optimization

JSON application logs contain endpoint, requestId, and status; retries can produce repeated failure events for one requestId. Which CloudWatch Logs Insights query identifies endpoints with more than 100 distinct failed requests in the selected time range?

Show the answer

Correct answerD. filter status >= 500 | stats count_distinct(requestId) as failures by endpoint | filter failures > 100

AWhy not this: Counting events includes repeated failure records for the same request and can inflate the result.

BWhy not this: Without filtering status, the aggregation counts successful requests as well as failed requests.

CWhy not this: Grouping by requestId makes each group's distinct request count one, preventing the threshold from being met.

DWhy this is right: Filtering failures before counting distinct request IDs per endpoint avoids counting repeated failure events.

Filter failure events, count distinct request IDs per endpoint, then filter the aggregated counts. Counting events instead would inflate totals when retries produce repeated failure records for the same request.