Question

Difficulty: MediumMonitoring and Analyzing Logs with Amazon CloudWatch

An application logs processing metrics to Amazon CloudWatch Logs in JSON format. A developer needs to write an Amazon CloudWatch Logs Insights query to analyze application performance. The query must only include log events where the `durationMs` field is present. Additionally, the query must calculate both the average and the 95th percentile of `durationMs` grouped in 10-minute intervals. Which TWO CloudWatch Logs Insights query clauses must the developer include to meet these requirements?

  1. filter ispresent(durationMs)Answer
  2. stats avg(durationMs), pct(durationMs, 95) by bin(10m)Answer
  3. C
    filter durationMs exists
  4. D
    stats mean(durationMs), pct(durationMs, 95) by bin(10m)
  5. E
    stats avg(durationMs), pct(durationMs, 95) by 10m

Answer

The correct query clauses are the filter clause with the ispresent function and the stats clause using the avg and pct functions grouped by the bin function.
The filter clause utilizing the ispresent function correctly filters for events where the specific field exists. The stats clause correctly calculates the average using avg and the percentile using pct, and groups them in 10-minute buckets using the bin function.

Step-by-Step Solution

1
Identify the clause needed to filter log events based on the existence of a field.
The query must use the filter command combined with the ispresent(field) function.
This excludes log events that do not contain the target field from the calculation.
2
Determine the correct aggregation functions for average and percentile calculations.
Use the avg() function for average and the pct() function for percentiles.
CloudWatch Logs Insights query syntax specifies avg and pct (or percentile) as the supported aggregation operations.
3
Determine the syntax to group logs into temporal buckets.
Use the by bin(10m) clause.
The bin function is required to group aggregate statistics into discrete time buckets like 10-minute intervals.

Key Concept

Writing syntactically correct CloudWatch Logs Insights queries to filter and aggregate log data.
Rate this question