The Splunk SDK for Python
We understood the use of an SDK and also saw the installation part of the Splunk SDK for Python. Now, we will see how the SDK can be used to integrate the power of Splunk's analytics and visualization.
Importing the Splunk API in Python
The following import
statement will make the Splunk API available for use in Python:
import splunklib.client as client import splunklib.results as results
The preceding two import
statements make the API exposed using the Splunk SDK that is to be used in the Python code for integration.
Connecting and authenticating the Splunk server
The following image in the code snippet connects and also authenticates the Splunk server. The login details can be passed as a parameter when running the Python code or can be hardcoded in the code itself and can be saved in a .splunkrc
file:
Once the authentication is successful, the Splunk APIs can be used to send data on Splunk, enlist or run saved searches, run a search query on Splunk, upload files...