Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Readme update #503

Merged
merged 2 commits into from
Jan 23, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 33 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,39 @@ class GeneratorTest(GeneratingCommand):
checkpoint_dir = inputs.metadata["checkpoint_dir"]
```

#### Optional:Set up logging for splunklib
### Access service object in Custom Search Command & Modular Input apps

#### Custom Search Commands
* The service object is created from the Splunkd URI and session key passed to the command invocation the search results info file.
* Service object can be accessed using `self.service` in `generate`/`transform`/`stream`/`reduce` methods depending on the Custom Search Command.
* For Generating Custom Search Command
```python
def generate(self):
# other code

# access service object that can be used to connect Splunk Service
service = self.service
# to get Splunk Service Info
info = service.info
```



#### Modular Inputs app:
* The service object is created from the Splunkd URI and session key passed to the command invocation on the modular input stream respectively.
* It is available as soon as the `Script.stream_events` method is called.
```python
def stream_events(self, inputs, ew):
# other code

# access service object that can be used to connect Splunk Service
service = self.service
# to get Splunk Service Info
info = service.info
```


### Optional:Set up logging for splunklib
+ The default level is WARNING, which means that only events of this level and above will be visible
+ To change a logging level we can call setup_logging() method and pass the logging level as an argument.
+ Optional: we can also pass log format and date format string as a method argument to modify default format
Expand Down