Getting Data In

With Python Splunk SDK stop raise HTTPError(response) for 504 responses

Path Finder

Our Splunk environment sometimes throws 504 errors when we query via the API, which has been a known issue for a while. We recently moved a connector to using the Python sdk over a hacky script we had. In our API based one, we were able to catch the 504 errors that pop up randomly and loop back and try again when they happen. With the Python SDK, the best I've been able to find out to do is this:

flag = True
        while flag:
                job =|results|any jobs./job. call)(query, **kwargs_normalsearch)
                flag = False
            except binding.HTTPError:
                    print('Splunk 504 Error'

But this has a lot of problems, especially since if any other errors besides a 504 pop up that would actually indicate a real problem, I'm going to be stuck in a never ending loop. If there's a parameter or something for the jobs/job object that allows for ignoring specific HTTP errors? I'd really like to stop wrapping these calls in silly while True loops. If not is there a way to extract the status from the exception that's raised and at least be able to handle different status codes in different ways?

0 Karma
Don’t Miss Global Splunk
User Groups Week!

Free LIVE events worldwide 2/8-2/12
Connect, learn, and collect rad prizes
and swag!