Courseiva
Basic Searching and Transforming CommandsmediumMultiple ChoiceObjective-mapped

Calculating Average per Group with stats

A team needs to calculate the average response time for each URL path from web server logs. The response time is in a field 'duration'. Which search is correct?

Quick Answer

The answer is `index=web | stats avg(duration) by url_path`. This is correct because the `stats` command with a `by` clause calculates the average of the `duration` field for each distinct value of `url_path`, effectively grouping the data by URL path before applying the aggregation. On the Splunk Core Certified User SPLK-1002 exam, this tests your understanding of how `stats` with `by` creates per-group results, a common requirement for analyzing web server logs. A frequent trap is forgetting the `by` clause, which would return a single overall average instead of per-path averages. To remember, think of `by` as the "grouping key" that splits your data into buckets before the aggregation function runs. A useful memory tip: "Stats with 'by' means 'average for each' — without it, you get 'average for all'."

⚠ Common exam trap

Test-takers frequently confuse `stats` with `chart` or `timechart`, or incorrectly try to use `eval` for aggregation, not realizing that `eval` operates on individual events and cannot compute summary statistics across groups.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

index=web | stats avg(duration) by url_path

The `stats avg(duration) by url_path` command computes the average of the 'duration' field for each distinct value of 'url_path', exactly matching the requirement to calculate average response time per URL path. The `stats` command with a `by` clause groups results by the specified field and applies the aggregation function to each group.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • index=web | timechart avg(duration) by url_path

    Why it's wrong here

    timechart adds time dimension, not needed.

  • index=web | chart avg(duration) by url_path

    Why it's wrong here

    chart can be used but stats is more common for this.

  • index=web | eval avg_duration=avg(duration) | stats by url_path

    Why it's wrong here

    eval avg(duration) is invalid as avg cannot be used in eval.

  • index=web | stats avg(duration) by url_path

    Why this is correct

    stats correctly computes average per group.

About these practice questions

This SPLK-1001 question is part of Courseiva's 502-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

Same concept, more angles

1 more way this is tested on SPLK-1001

These questions test the same concept from different angles. Work through them to make sure you can recognise it however the exam phrases it.

Variation 1. A user needs to create a report showing the average response time per endpoint for the last hour. Which command would produce this result?

medium
  • A.chart avg(response_time) over endpoint
  • B.eval avg(response_time)
  • C.top endpoint
  • D.stats avg(response_time) by endpoint

Why D: The `stats` command with `avg(response_time) by endpoint` calculates the average response time for each unique endpoint, which directly meets the requirement of showing average response time per endpoint for the last hour. The `stats` command is the standard way to compute aggregate statistics like average over grouped fields in Splunk.

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This SPLK-1001 practice question is part of Courseiva's free Splunk certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the SPLK-1001 exam.