Splunk Search

how to find what commands in the search language are being used

harishsplunk7
Explorer

I want to list what commands in the search language are being used.  I think its possible in the same _audit index and  I want to be able to do is count the number of times each command is used in search

Example : 

stats used 2 time

eval used 5 times 

rex used 7 time

timechart used 10 time

 

Tags (1)
0 Karma

richgalloway
SplunkTrust
SplunkTrust

There is a REST endpoint, /services/search/v2/parser,  you may be able to use to parse queries into the commands used.  It requires the POST method so it will have to be used from a script (not from the UI).  See https://docs.splunk.com/Documentation/Splunk/9.1.1/RESTREF/RESTsearch#search.2Fv2.2Fparser

---
If this reply helps you, Karma would be appreciated.

ITWhisperer
SplunkTrust
SplunkTrust

You could start with something like this:

index=_audit
| rex max_match=0 field=search "\|\s*(?<command>\w+)"
| stats count by command

However, you may get some false results if pipes are used in the search where they are not delimiting commands. Also, you may find that macros hide the use of some commands.

harishsplunk7
Explorer

Thank you, I am getting the result but unwanted fields are coming like jira, macro, filename. How to get rid of this from result

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust
| where command!="jira" AND command!="macro" AND command!="filename"
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 ...