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
Copy file name to clipboardexpand all lines: README.md
+49-33
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,7 @@
3
3
4
4
# The Splunk Enterprise Software Development Kit for Python
5
5
6
-
#### Version 1.6.18
6
+
#### Version 1.6.19
7
7
8
8
The Splunk Enterprise Software Development Kit (SDK) for Python contains library code and examples designed to enable developers to build applications using the Splunk platform.
9
9
@@ -60,7 +60,6 @@ You'll need `docker` and `docker-compose` to get up and running using this metho
60
60
```
61
61
make up SPLUNK_VERSION=8.0
62
62
make wait_up
63
-
make splunkrc_default
64
63
make test
65
64
make down
66
65
```
@@ -75,7 +74,7 @@ The SDK command-line examples require a common set of arguments that specify the
75
74
#### Using username/password
76
75
```python
77
76
import splunklib.client as client
78
-
service = client.connect(host=<host_url>, username=<username>, password=<password>, autoLogin=True)
77
+
service = client.connect(host=<host_url>, username=<username>, password=<password>, autologin=True)
79
78
```
80
79
81
80
#### Using bearer token
@@ -91,13 +90,13 @@ service = client.connect(host=<host_url>, token=<session_key>, autologin=True)
91
90
```
92
91
93
92
###
94
-
#### Create a .splunkrc convenience file
93
+
#### Update a .env file
95
94
96
-
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 login credentials for Splunk Enterprise. For convenience during development, you can store these arguments as key-value pairs in a text file named **.splunkrc**. Then, the SDK examples and unit tests use the values from the **.splunkrc** file when you don't specify them.
95
+
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 login credentials for Splunk Enterprise. For convenience during development, you can store these arguments as key-value pairs in a **.env** file. Then, the SDK examples and unit tests use the values from the **.env** file when you don't specify them.
97
96
98
-
>**Note**: Storing login credentials in the **.splunkrc** file is only for convenience during development. This file isn't part of the Splunk platform and shouldn't be used for storing user credentials for production. And, if you're at all concerned about the security of your credentials, enter them at the command line rather than saving them in this file.
97
+
>**Note**: Storing login credentials in the **.env** file is only for convenience during development. This file isn't part of the Splunk platform and shouldn't be used for storing user credentials for production. And, if you're at all concerned about the security of your credentials, enter them at the command line rather than saving them in this file.
99
98
100
-
To use this convenience file, create a text file with the following format:
99
+
here is an example of .env file:
101
100
102
101
# Splunk Enterprise host (default: localhost)
103
102
host=localhost
@@ -106,27 +105,15 @@ To use this convenience file, create a text file with the following format:
106
105
# Splunk Enterprise username
107
106
username=admin
108
107
# Splunk Enterprise password
109
-
password=changeme
108
+
password=changed!
110
109
# Access scheme (default: https)
111
110
scheme=https
112
111
# Your version of Splunk Enterprise
113
112
version=8.0
114
-
115
-
Save the file as **.splunkrc** in the current user's home directory.
116
-
117
-
* For example on OS X, save the file as:
118
-
119
-
~/.splunkrc
120
-
121
-
* On Windows, save the file as:
122
-
123
-
C:\Users\currentusername\.splunkrc
124
-
125
-
You might get errors in Windows when you try to name the file because ".splunkrc" appears to be a nameless file with an extension. You can use the command line to create this file by going to the **C:\Users\\<currentusername>** directory and entering the following command:
126
-
127
-
Notepad.exe .splunkrc
128
-
129
-
Click **Yes**, then continue creating the file.
113
+
# Bearer token for authentication
114
+
#bearerToken=<Bearer-token>
115
+
# Session key for authentication
116
+
#sessionKey=<Session-Key>
130
117
131
118
#### Run the examples
132
119
@@ -144,7 +131,7 @@ Using Session key
144
131
145
132
python examplename.py --sessionKey="<value>"
146
133
147
-
If you saved your login credentials in the **.splunkrc** file, you can omit those arguments:
134
+
If you saved your login credentials in the **.env** file, you can omit those arguments:
148
135
149
136
python examplename.py
150
137
@@ -212,19 +199,48 @@ class CustomStreamingCommand(StreamingCommand):
212
199
Do
213
200
```python
214
201
@Configuration()
215
-
classGeneratorTest(GeneratingCommand):
216
-
defgenerate(self):
217
-
yieldself.gen_record(_time=time.time(), one=1)
218
-
yieldself.gen_record(_time=time.time(), two=2)
202
+
classGeneratorTest(GeneratingCommand):
203
+
defgenerate(self):
204
+
yieldself.gen_record(_time=time.time(), one=1)
205
+
yieldself.gen_record(_time=time.time(), two=2)
219
206
```
220
207
221
208
Don't
222
209
```python
223
210
@Configuration()
224
-
classGeneratorTest(GeneratingCommand):
225
-
defgenerate(self):
226
-
yield {'_time': time.time(), 'one': 1}
227
-
yield {'_time': time.time(), 'two': 2}
211
+
classGeneratorTest(GeneratingCommand):
212
+
defgenerate(self):
213
+
yield {'_time': time.time(), 'one': 1}
214
+
yield {'_time': time.time(), 'two': 2}
215
+
```
216
+
217
+
### Access metadata of modular inputs app
218
+
* In stream_events() method we can access modular input app metadata from InputDefinition object
219
+
* See [GitHub Commit](https://github.com/splunk/splunk-sdk-python/blob/develop/examples/github_commits/bin/github_commits.py) Modular input App example for reference.
220
+
```python
221
+
defstream_events(self, inputs, ew):
222
+
# other code
223
+
224
+
# access metadata (like server_host, server_uri, etc) of modular inputs app from InputDefinition object
225
+
# here inputs is a InputDefinition object
226
+
server_host = inputs.metadata["server_host"]
227
+
server_uri = inputs.metadata["server_uri"]
228
+
229
+
# Get the checkpoint directory out of the modular input's metadata
0 commit comments