Monitoring Splunk

How to Start or Stop splunk service using SPlunk SDK

Manvir
New Member

Does someone know show to START and/or STOP splunk using Splunk SDK? Using CLI, we can do
splunk stop
splunk start
but I am looking for its equivalent using SDK.

Tags (2)
0 Karma
1 Solution

lguinn2
Legend

You can't start Splunk from the SDK because when Splunk is stopped, there is no running API. If splunkd is not running, there is "no one home" for your code to talk to!

But you could write a script to execute these commands in the OS, and use your code to launch the script.

View solution in original post

Manvir
New Member

Thanks that helps ! I created a batch file with these commands.

0 Karma

lguinn2
Legend

You can't start Splunk from the SDK because when Splunk is stopped, there is no running API. If splunkd is not running, there is "no one home" for your code to talk to!

But you could write a script to execute these commands in the OS, and use your code to launch the script.

arjun_hcl
Explorer

Is there any way to get the status of splunkd service through sdk??

0 Karma

Manvir
New Member

Basically rather than just restarting, I want to first stop then clean the index and then Start.
Actually, I want to do the equivalent of this using SDK.

Splunk stop
splunk clean eventdata -index default –f
splunk start

0 Karma

lpolo
Motivator

In python under splunklib.client you have the service class as well. From here you can use restart method to restart your splunkd instance.

0 Karma

somesoni2
Revered Legend

In java or C# SDK, you have a class "Service" which contains a method Restart.

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!

Index This | What travels the world but is also stuck in place?

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

Discover New Use Cases: Unlock Greater Value from Your Existing Splunk Data

Realizing the full potential of your Splunk investment requires more than just understanding current usage; it ...

Continue Your Journey: Join Session 2 of the Data Management and Federation Bootcamp ...

As data volumes continue to grow and environments become more distributed, managing and optimizing data ...