File tree Expand file tree Collapse file tree 1 file changed +33
-1
lines changed Expand file tree Collapse file tree 1 file changed +33
-1
lines changed Original file line number Diff line number Diff line change @@ -209,7 +209,39 @@ class GeneratorTest(GeneratingCommand):
209
209
checkpoint_dir = inputs.metadata[" checkpoint_dir" ]
210
210
```
211
211
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
213
245
+ The default level is WARNING, which means that only events of this level and above will be visible
214
246
+ To change a logging level we can call setup_logging() method and pass the logging level as an argument.
215
247
+ Optional: we can also pass log format and date format string as a method argument to modify default format
You can’t perform that action at this time.
0 commit comments