Splunk Search

Multi-column stats: average and count for a column

isnoop
New Member

I am building a search to find the average amount of time an action takes:

sourcetype="timelog" | stats avg(request_duration) by requested_file

However, I would also like to see the number of hits represented in that average which I would intuitively write like so:

sourcetype="timelog" | stats avg(request_duration), count(request_duration) by requested_file

Of course, this is invalid syntax because stats only allows one input column.

What is the proper way to write this search?

Tags (3)
0 Karma

gkanapathy
Splunk Employee
Splunk Employee

The stats command allows many input columns and many aggregation functions on any or all of them. The above syntax is valid and correct for what you have stated.

Get Updates on the Splunk Community!

Adoption of RUM and APM at Splunk

    Unleash the power of Splunk Observability   Watch Now In this can't miss Tech Talk! The Splunk Growth ...

Routing logs with Splunk OTel Collector for Kubernetes

The Splunk Distribution of the OpenTelemetry (OTel) Collector is a product that provides a way to ingest ...

Welcome to the Splunk Community!

(view in My Videos) We're so glad you're here! The Splunk Community is place to connect, learn, give back, and ...