View all files | ||||
The Splunk Enterprise Software Development Kit (SDK) for Python is intended to be the primary way for developers to communicate with the Splunk platform's REST API.
You may be asking:
Using uv:
If you prefer not using uv, using pip should work as expected:
Because of the way Splunk Apps are built, you need to install your external dependencies to bin/lib/ for the App to work. Then in your App script files:
An example workflow to package your App for uploading to Splunk (expect to modify it heavily):
See docs for more details.
The easiest and most effective way of learning how to use this library should be reading through the apps in our test suite, as well as the splunk-app-examples repository. They show how to programmatically interact with the Splunk platform in a variety of scenarios - from basic metadata retrieval, one-shot searching and managing saved searches to building complete applications with modular inputs and custom search commands.
For details, see the examples using the Splunk Enterprise SDK for Python on the Splunk Developer Portal, as well as the Splunk Enterprise SDK for Python Reference
You can now leverage AI capabilities within your Splunk Apps using the splunklib.ai package. Take a look at its README to find out how to enhance your Apps agentic behaviour, custom tools and more.
TODO: Link docs about this
When working with custom search commands such as Custom Streaming Commands or Custom Generating Commands, we may need to add new fields to the records based on certain conditions. Structural changes like this may not be preserved. If you're having issues with field retention, make sure to use add_field(record, fieldname, value) method from SearchCommand to add a new field and value to the record.
Go here to find out more about setting up a Modular Input.
In stream_events() you can access Modular Input app metadata from InputDefinition object
See the Modular Input App example for reference.
We welcome all contributions! If you would like to contribute to the SDK, see Contributing to Splunk. For additional guidelines, see CONTRIBUTING.
Make sure you have uv and docker/podman installed and available in your $PATH. Run make uv-sync to get a virtualenv set up or updated. After activating it with source .venv/bin/activate you should be ready to go!
To connect to Splunk Enterprise, many of the SDK examples and unit tests take command-line arguments that specify values for the host, port, and authentication. For convenience during development, you can store these arguments as key-value pairs in an .env file.
A file called .env.template exists in the root of this repository. Duplicate it as .env, then adjust it to your match your environment.
WARNING: The .env file isn't part of the Splunk platform. This is not the place for production credentials!
This repository contains a suite of unit and integration tests.
The integration suite requires docker/podman to work.
NOTE: Before running the integration tests, make sure the instance of Splunk you are testing against doesn't have new events being dumped continuously into it. Several of the tests rely on a stable event count. It's best to test against a clean install of Splunk but if you can't, you should at least disable the *NIX and Windows apps.
Do not run the test suite against a production instance of Splunk! It will run just fine with the free Splunk license.
The default level is WARNING, which means that only events of this level and above will be visible To change a logging level we can call setup_logging() method and pass the logging level as an argument.
Optionally, you can also provide a custom log and date format string. When in doubt, always refer to the source code.
| Splunk Developer Portal | General developer documentation, tools, and examples |
| Integrate the Splunk platform using development tools for Python | Documentation for Python development |
| Splunk Enterprise SDK for Python Reference | SDK API reference documentation |
| REST API Reference Manual | Splunk REST API reference documentation |
| Splunk>Docs | General documentation for the Splunk platform |
| GitHub Wiki | Documentation for this SDK's repository on GitHub |
| Splunk Enterprise SDK for Python Examples | Examples for this SDK's repository |
Stay connected with other developers building on the Splunk platform.
You will be granted support if you or your company are already covered under an existing maintenance/support agreement. Submit a new case in the Support Portal and include at least Splunk Enterprise SDK for Python in the subject line.
If you are not covered under an existing maintenance/support agreement, you can find help through the broader community at Splunk Answers.
Splunk will NOT provide support for SDKs if the core library (code in the /splunklib directory) has been modified. If you modify the SDK and want support, try finding it with the broader community, e.g. Splunk Answers.
That said, we'd also like to know why you felt the need to modify the core library, so please send feedback and file any issues in our GitHub Issues.