Splunk Search

Enlist size of files and directories in acsending order

hishamjan
Explorer

Hi,

Is there a way to enlist the size of files that are indexed using the local host and universal forwarders? Screenshot 2021-02-23 at 4.41.44 PM 1.png

From the above screenshot, I have 2 forwarders and fifteenforty is the search head. 

Is it possible to create a table of the largest files, smallest files, total files by each host or something close to that?

 

Any degree of help will be appreciated.

 

Regards,

Hisham

Labels (4)
0 Karma

richgalloway
SplunkTrust
SplunkTrust

Try this query for starters.

index=foo
```Get the size of each event```
| eval bytes=len(_raw) 
```Add sizes by source and host```
| stats sum(bytes) as bytes by source,host 
```Get a count of files for each host```
| eventstats dc(source) as fileCount by host 
```Sort by host and size so we can find the largest and smallest files```
| sort - host bytes 
```Number the results```
| streamstats reset_on_change=1 count as rank by host 
```Get the highest number for each host```
| eventstats max(rank) as maxRank by host 
```Filter out all except the first and last 5 results```
```Change 5 to get a different number of largest or smallest files```
| where (rank<=5 OR rank>=maxRank-5) 
| table host fileCount source bytes
---
If this reply helps you, Karma would be appreciated.
0 Karma

hishamjan
Explorer

Hi @richgalloway 

 

Thanks for the response.

 

I tried this out but it gives a very vague data output.

 

What I'm precisely looking for is the largest files per host, i.e. if I have 6 hosts let's assume, I would want to know the largest file for every six hosts, their sizes as well as the name/path of that largest file.

 

Hope you understand what I'm looking for.

 

Regards, 

Hisham

0 Karma

richgalloway
SplunkTrust
SplunkTrust

"Is it possible to create a table of the largest files, smallest files, total files by each host or something close to that?"

"I would want to know the largest file for every six hosts, their sizes as well as the name/path of that largest file."

Thank you for changing the requirements.  I believe the existing answer has the information you need.  Just remove the parts you don't need.

---
If this reply helps you, Karma would be appreciated.
0 Karma
Get Updates on the Splunk Community!

Index This | Forward, I’m heavy; backward, I’m not. What am I?

April 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

A Guide To Cloud Migration Success

As enterprises’ rapid expansion to the cloud continues, IT leaders are continuously looking for ways to focus ...

Join Us for Splunk University and Get Your Bootcamp Game On!

If you know, you know! Splunk University is the vibe this summer so register today for bootcamps galore ...