Getting Data In

Can REST API be used to execute a python script on Splunk server?


Could we add a custom python script on our Splunk server and have it executed from a client using the Splunk REST API?


Are you looking for something like this

0 Karma


SOLVED for similar case
"Error when I run custom Python script from one server to another sever using cURL (Search Factory: Unknown search command)"

0 Karma


Yes you can do that. One of the way is Modular Inputs.

0 Karma

Path Finder

Yes! One way to do this is with a custom search command. Let's say your python script is called "testscript". You could rewrite as (or call it from) a Python script that Splunk recognizes as a custom search command, and then you could execute it as a Splunk search like this: "| testscript". Then you could call that search (adding arguments as needed) using the Splunk REST API.

Here's a link that explains how to create custom search commands:
Here's the basic documentation on running a search from Python using Splunk's REST API:


why this does not work from a Linux myServer2?
curl -k -u 'myUser:myPwd' https://myServer1:8089/services/search/jobs/export -d search=" | makeresults | myScript " -d output_mode=csv

But OK for search = " | makeresults | eval myVal=777 "

0 Karma


Again. So poor support here...

0 Karma
Get Updates on the Splunk Community!

Improve Your Security Posture

Watch NowImprove Your Security PostureCustomers are at the center of everything we do at Splunk and security ...

Maximize the Value from Microsoft Defender with Splunk

 Watch NowJoin Splunk and Sens Consulting for this Security Edition Tech TalkWho should attend:  Security ...

This Week's Community Digest - Splunk Community Happenings [6.27.22]

Get the latest news and updates from the Splunk Community here! News From Splunk Answers ✍️ Splunk Answers is ...