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

Modinput preserve 'app' context #371

Merged
merged 3 commits into from
Jan 11, 2022

Conversation

lowell80
Copy link
Contributor

@lowell80 lowell80 commented Mar 13, 2021

Add the ability to track the app namespace for modular inputs. This information is available in the XML passed in via stdin, but has not been available to modular input code using splunklib. Having access to app allows additional interactions with the REST API to be properly namespaces, for example if you need to lookup a password or other conf entry that lives in the same namespace as the input stanza.

Example use case with the updated code:

def stream_events(self, inputs, ew):
    for input_name, input_item in inputs.inputs.items():
        app = self.service.namespace["app"] = input_item["__app"]
        my_pass = self.service.storage_passwords["my_password"]

I picked the name __app to avoid potential naming conflicts with entries in inputs.conf, but it's a bit arbitrary. I'd be happy to change it if there are strong preferences to the contrary.

@bparmar-splunk
Copy link
Contributor

Hi @lowell80,
We have tried to implement these changes but we have encountered some errors while executing test cases.
We look forward to review it again, if you push these changes (including conflicts resolved) with regards to newer sdk version.

Also, test cases will be automatically triggered (using github workflow) when changes are pushed. So it would help us to resolve, if any error occurs.

- Update modularinput XML parsing to capture the 'app' tag for configuration
  stanza elements.  This value is stored in the input dict under '__app' to
  avoid potential naming collisions with user defined parameters.
- Updated unittest
@lowell80
Copy link
Contributor Author

lowell80 commented Jan 7, 2022

@bparmar-splunk, I've rebased my branch on the develop branch, but some of the test are failing. I suspect this is related to things outside the changes I made. Can you take a look at the test logs and determine if this is an issue with my code?

Between action job 182 (incorrect rebase mistake by me) and 183 (rebase on develop) I see the errors:

  • [Errno 104] Connection reset by peer
  • HTTP 500 Internal Server Error -- already reloading or shutting down, will not reload

@bparmar-splunk
Copy link
Contributor

Hi @lowell80,
I have re-initiated test run and all checks are passed. Hence, all code looks good.

@ashah-splunk ashah-splunk merged commit 9389ba2 into splunk:develop Jan 11, 2022
@akaila-splunk akaila-splunk mentioned this pull request Mar 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants