Splunk Search

How to generate a search to display the count of a field based on filepath extensions?

rvinjana
Explorer

I have a search with multiple extensions in a field which, i want to group details based on the extensions in filepath and also count based on the extensions in the filepath

devicename time fileHash filePath=.txt , .exe , .js etc

any help would be appreciated

Tags (2)
1 Solution

koshyk
Super Champion

Just tried with a small subset. Have a try using your dataset and let us know the results

index=_internal| stats count by source| rex field=source "\.(?<extn>[^\\\|^\/|^\.]+$)"| stats count by extn

so in your case, the actual search would be something like

<your search>  | rex field=filePath "\.(?<extn>[^\\\|^\/|^\.]+$)"| stats count by extn

View solution in original post

koshyk
Super Champion

Just tried with a small subset. Have a try using your dataset and let us know the results

index=_internal| stats count by source| rex field=source "\.(?<extn>[^\\\|^\/|^\.]+$)"| stats count by extn

so in your case, the actual search would be something like

<your search>  | rex field=filePath "\.(?<extn>[^\\\|^\/|^\.]+$)"| stats count by extn

rvinjana
Explorer

that worked thanks a lot

0 Karma
Get Updates on the Splunk Community!

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...