splunk-sdk-python icon indicating copy to clipboard operation
splunk-sdk-python copied to clipboard

Get requests for particular monitor inputs fail because paths are not converted before sending the request

Open jasonbeyers opened this issue 13 years ago • 2 comments

It's probably easiest to describe the issue with an example.

First, create a new monitor input

s = splunklib.connect(...) s.inputs.create('/home/myuser/log', kind='monitor')

I see a POST with name='%2Fhome%2Fmyuser%2Flog' in the message body, and the splunk instance correctly handles it. However, the subsequent GET (which I presume is used to update the state locally) uses the path I provided, /home/myuser/log. Because of this, or maybe something else, I immediately get this:

splunklib.binding.HTTPError: HTTP 404 Not Found -- In handler 'monitor': Invalid custom action for this internal handler (handler: monitor, custom action: myuser, eai action: list).

Any subsequent attempts to lookup the Input object for this monitor input, using:

s.inputs['/home/myuser/log']

OR

s.inputs[('/home/myuser/log', 'monitor')]

...Fail with a KeyError. However, the following does work:

s.inputs['%2Fhome%2Fmyuser%2Flog']

This is pretty confusing. It seems like /home/myuser/log should work everytime from a custom script that uses the SDK, and that the URL-valid paths (with the %2F sequences) should remain from the user.

Is this intended behavior?

Thanks, -Jason [email protected] (perf)

jasonbeyers avatar Nov 26 '13 23:11 jasonbeyers

I notice the conversion from /home/myuser/log to %2Fhome%2Fmyuser%2Flog seems to happen on line 1071 of binding.py, when the initial POST is made.

I see no such conversion when performing a lookup of monitor /home/myuser/log (with a GET). Could this be the issue? Maybe something in how the UrlEncoded class is defined?

jasonbeyers avatar Nov 26 '13 23:11 jasonbeyers

Sorry about the delay on this fix. The input.create(...) function would actually create the input file, but was returning a bad Input object and an error message. I've gone ahead and fixed the create function and will push it ASAP.

As for the s.inputs['my/input'], according to the REST API http://docs.splunk.com/Documentation/Splunk/latest/RESTAPI/RESTinput#data.2Finputs.2Fmonitor The GET call for inputs requires the name to be URL encoded, s.inputs['my%2Finput']

We'll add functionality to accept both types of URL encoded names.

stelles avatar Jun 25 '14 00:06 stelles