Splunk Search

Running a custom command via cli

rabrahaham
Engager

Hello All,

We created a custom search on splunk which calculates a specific metric on all the servers that are part of the distributed search. I wanted to find out if its possible to run this custom search on splunk servers which are not part of the distributed search via GUI or CLI. when I try running 

/opt/splunk/bin/splunk search 'customsearchcommand inputs' -uri https://172.31.2.100:8089 (172.31.2.100 is not part of the distributed search) it says customsearchcommand not found. The custom search command is only present on the search head and it is working perfectly on all the distributed search peers without having the custom search defined there. 

 

Thanks

Labels (1)
0 Karma

The_Simko
Path Finder

What you are experience is how search operates.  
The Search Head, where your custom command exists, regularly sends its knowledge objects to the search peers. That way, when the Search Head requests a search, the peers use the knowledge objects provided by the search head.    

Since you went to a different indexer that is not a search peer of your search head, it will not have the search head's knowledge objects, and ergo, won't run your custom command. 

It's surprising that the custom search command functions directly at the CLI on the search peers at all. The KO transfer must be registering the object.  (possible that I'm butchering the terms here).  

Solution, package your custom command into an app and load that app on the indexers you want to run the command on.

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

[Puzzles] Solve, Learn, Repeat: Matching cron expressions

This puzzle (first published here) is based on matching timestamps to cron expressions.All the timestamps ...

Why Splunk Customers Should Attend Cisco Live 2026 Las Vegas

Why Splunk Customers Should Attend Cisco Live 2026 Las Vegas     Cisco Live 2026 is almost here, and this ...

Data Management Digest – May 2026

Welcome to the May 2026 edition of Data Management Digest!   As your trusted partner in data innovation, the ...