You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Please use the latest Python version supported when developing. Splunk Enterprise SDK for Python is tested with Python 3.9 and 3.13.
24
+
### Installing the SDK
24
25
25
-
#### Splunk Enterprise
26
+
Using `uv`:
26
27
27
-
This SDK is only tested with Splunk Enterprise versions supported in the [Splunk Software Support Policy](https://www.splunk.com/en_us/legal/splunk-software-support-policy.html).
28
+
```python
29
+
uv init
30
+
uv add splunk-sdk
31
+
uv sync
32
+
```
28
33
29
-
[Go here](http://www.splunk.com/download) to get Splunk Enterprise.
34
+
If you prefer not using `uv`, using `pip` should work as expected:
30
35
31
-
### Installing the SDK
36
+
```sh
37
+
python3 -m venv .venv
38
+
source .venv/bin/activate
39
+
python3 -m pip install splunk-sdk
40
+
```
32
41
33
-
Using `pip` is the easiest way to pull the SDK into your project. `poetry` and `uv` should work just as well. A project-specific virtualenv is recommended.
42
+
### Including external dependencies in your App
34
43
35
-
In your app's project folder:
44
+
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):
36
53
37
54
```sh
38
-
python -m venv .venv
39
-
source .venv/bin/activate
40
-
python -m pip install splunk-sdk --target bin/
55
+
python3 -m pip install . \
56
+
--target bin/lib/ \
57
+
# Needs to match the platform Splunk is built and
58
+
# ran on, NOT the one you're writing your App on
59
+
--platform manylinux2014_aarch64 \
60
+
--only-binary=:all:
61
+
62
+
gtar --transform='s,^,<your_app>/,' \
63
+
--exclude="__pycache__" \
64
+
-czf dist/<your_app>.tgz \
65
+
bin default
66
+
67
+
# `<your_app>.tgz` should be now ready in `dist/`!
41
68
```
42
69
43
-
Install your dependencies into `bin/` if bundling with an app, otherwise you can skip it.
44
-
[See docs](https://dev.splunk.com/enterprise/docs/developapps/createapps/appanatomy/) on more details about packaging additional dependencies with your app.
70
+
[See docs](https://dev.splunk.com/enterprise/docs/developapps/createapps/appanatomy) for more details.
45
71
46
-
### Using SDK in apps
72
+
### Using SDK in Splunk Apps
47
73
48
74
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](https://github.com/splunk/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.
49
75
@@ -166,27 +192,38 @@ class MyScript(Script):
166
192
We welcome all contributions!
167
193
If you would like to contribute to the SDK, see [Contributing to Splunk](https://www.splunk.com/en_us/form/contributions.html). For additional guidelines, see [CONTRIBUTING](CONTRIBUTING.md).
168
194
169
-
#### Testing
195
+
###Setting up a development environment
170
196
171
-
This repository contains both unit and integration tests. The latter need `docker`/`podman` to work.
197
+
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!
172
198
173
-
##### Create an `.env` file
199
+
####Creating an `.env` file
174
200
175
-
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 a`.env` file.
201
+
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.
176
202
177
203
A file called `.env.template` exists in the root of this repository. Duplicate it as `.env`, then adjust it to your match your environment.
178
204
205
+
```sh
206
+
cp .env.template .env
207
+
```
208
+
179
209
> **WARNING:** The `.env` file isn't part of the Splunk platform. This is **not** the place for production credentials!
180
210
211
+
#### Testing
212
+
213
+
This repository contains a suite of unit and integration tests.
214
+
181
215
```sh
182
216
# Run entire test suite:
183
217
make test
218
+
184
219
# Run only the unit tests:
185
220
make test-unit
186
221
```
187
222
188
223
##### Integration tests
189
224
225
+
The integration suite requires `docker`/`podman` to work.
226
+
190
227
> 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.
191
228
192
229
```sh
@@ -200,7 +237,7 @@ make test-integration
200
237
201
238
> Do not run the test suite against a production instance of Splunk! It will run just fine with the free Splunk license.
202
239
203
-
###Setting up logging for splunklib
240
+
#### Enabling logging in `splunklib`
204
241
205
242
The default level is WARNING, which means that only events of this level and above will be visible
206
243
To change a logging level we can call setup_logging() method and pass the logging level as an argument.
-[Issues and pull requests](https://github.com/splunk/splunk-sdk-python/issues/)
273
+
-[Send an e-mail to Splunk Dev Platform](mailto:devinfo@splunk.com)
238
274
239
-
###Support
275
+
## Support
240
276
241
-
- 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](https://www.splunk.com/en_us/support-and-services.html) and include `Splunk Enterprise SDK for Python` in the subject line.
277
+
- 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](https://www.splunk.com/en_us/support-and-services.html) and include at least `Splunk Enterprise SDK for Python` in the subject line.
242
278
243
279
If you are not covered under an existing maintenance/support agreement, you can find help through the broader community at [Splunk Answers](https://community.splunk.com/t5/Splunk-Development/ct-p/developer-tools).
244
280
245
-
- Splunk will NOT provide support for SDKs if the core library (the code in the `/splunklib` directory) has been modified. If you modify an SDK and want support, you can find help through the broader community and [Splunk Answers](https://community.splunk.com/t5/Splunk-Development/ct-p/developer-tools).
246
-
247
-
We would also like to know why you modified the core library, so please send feedback to [devinfo@splunk.com](mailto:devinfo@splunk.com).
248
-
249
-
- File any issues on [GitHub](https://github.com/splunk/splunk-sdk-python/issues).
250
-
251
-
### Contact us
281
+
- 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](https://community.splunk.com/t5/Splunk-Development/ct-p/developer-tools).
252
282
253
-
You can reach the Splunk Developer Platform team at [devinfo@splunk.com](mailto:devinfo@splunk.com).
283
+
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](https://github.com/splunk/splunk-sdk-python/issues).
0 commit comments