Splunk Search

extract top ten values

jip31jip31
Explorer

hi
i use this code
index="wineventlog" sourcetype="wineventlog:" SourceName="" Type="Critique" OR Type="Avertissement" | dedup _time SourceName | table _time SourceName | stats count by SourceName

and i would like to keep only the ten important values
how to do it please???

Tags (1)
0 Karma
1 Solution

kmaron
Motivator
index="wineventlog" sourcetype="wineventlog:" SourceName="" Type="Critique" OR Type="Avertissement" 
| dedup _time SourceName 
| table _time SourceName 
| stats count by SourceName
| sort - count limit=10

Sort by the field you want the top 10 of. (I used your count)
Then set limit= for how many you want to keep.

View solution in original post

tpeveler_splunk
Splunk Employee
Splunk Employee

Hello,

The most straight forward way to handle this would be to use the top command.

A couple of things to note. You'll want to wildcard your sourcetype so that you do indeed pickup the wineventlog sourcetypes (i.e. sourcetype="wineventlog:*"). In addition, you'll want to wrap the OR condition on the Type fields in parenthesis as such (Type="Critique" OR Type="Avertissement")

SPL...

index="wineventlog" sourcetype="wineventlog:*" SourceName="" (Type="Critique" OR Type="Avertissement")
| dedup _time SourceName
| top limit=10 SourceName

0 Karma

kmaron
Motivator
index="wineventlog" sourcetype="wineventlog:" SourceName="" Type="Critique" OR Type="Avertissement" 
| dedup _time SourceName 
| table _time SourceName 
| stats count by SourceName
| sort - count limit=10

Sort by the field you want the top 10 of. (I used your count)
Then set limit= for how many you want to keep.

adonio
Ultra Champion

use the top command? ... | top limit=10 SourceName
or maybe sort command ... | sort 10 - count

0 Karma
Get Updates on the Splunk Community!

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer at Splunk .conf24 ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...

Share Your Ideas & Meet the Lantern team at .Conf! Plus All of This Month’s New ...

Splunk Lantern is Splunk’s customer success center that provides advice from Splunk experts on valuable data ...