Skip to content

Commit 6be3ddf

Browse files
authored
Merge pull request #503 from splunk/readme-update
Readme update
2 parents eeb0ffe + 83d7534 commit 6be3ddf

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

README.md

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,39 @@ class GeneratorTest(GeneratingCommand):
209209
checkpoint_dir = inputs.metadata["checkpoint_dir"]
210210
```
211211

212-
#### Optional:Set up logging for splunklib
212+
### Access service object in Custom Search Command & Modular Input apps
213+
214+
#### Custom Search Commands
215+
* The service object is created from the Splunkd URI and session key passed to the command invocation the search results info file.
216+
* Service object can be accessed using `self.service` in `generate`/`transform`/`stream`/`reduce` methods depending on the Custom Search Command.
217+
* For Generating Custom Search Command
218+
```python
219+
def generate(self):
220+
# other code
221+
222+
# access service object that can be used to connect Splunk Service
223+
service = self.service
224+
# to get Splunk Service Info
225+
info = service.info
226+
```
227+
228+
229+
230+
#### Modular Inputs app:
231+
* The service object is created from the Splunkd URI and session key passed to the command invocation on the modular input stream respectively.
232+
* It is available as soon as the `Script.stream_events` method is called.
233+
```python
234+
def stream_events(self, inputs, ew):
235+
# other code
236+
237+
# access service object that can be used to connect Splunk Service
238+
service = self.service
239+
# to get Splunk Service Info
240+
info = service.info
241+
```
242+
243+
244+
### Optional:Set up logging for splunklib
213245
+ The default level is WARNING, which means that only events of this level and above will be visible
214246
+ To change a logging level we can call setup_logging() method and pass the logging level as an argument.
215247
+ Optional: we can also pass log format and date format string as a method argument to modify default format

0 commit comments

Comments
 (0)