Splunk Search

How to limit results with multiple group by conditions?

alchang
Explorer

Can the limit command be used with multiple conditions?

My search query is as follows | stats count as num by searchTerm, domain. I want to return the top 3 searchterms per domain. Is there a way to do that from the search bar in splunk UI?

Desired Output:

Domain searchTerm Number
Google ABC 100
Google DEF 50
Google GHI 25
Yahoo DEF 75
Yahoo ABC 60
Yahoo JKL 20
Bing DEF 80
Bing JKL 40
Bing GHI 20

Tags (3)
0 Karma

MuS
SplunkTrust
SplunkTrust

Hi alchang,

try something like this:

your base search here 
| stats count as num by searchTerm, domain
| sort domain, -num 
| streamstats num as rank by domain
| where rank < 4

Hope this helps to get you started ...

cheers, MuS

alchang
Explorer

Thanks! That worked. I hadn't worked much with streamstats before, but it looks very powerful. I will check it out. Offhand, do you know if streamstats works with report acceleration?

0 Karma

MuS
SplunkTrust
SplunkTrust

According to the docs http://docs.splunk.com/Documentation/Splunk/6.2.1/Report/Acceleratereports#How_reports_qualify_for_r... only transforming commands qualify for report acceleration. Find a list of transforming commands here http://docs.splunk.com/Splexicon:Transformingcommand

Feel free to accept this answer if it answered your question - you get some kudos as well 😉

0 Karma
Get Updates on the Splunk Community!

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 ...

Tech Talk | Elevating Digital Service Excellence: The Synergy of Splunk RUM & APM

Elevating Digital Service Excellence: The Synergy of Real User Monitoring and Application Performance ...