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
Get Updates on the Splunk Community!

Maximize the Value from Microsoft Defender with Splunk

 Watch NowJoin Splunk and Sens Consulting for this Security Edition Tech TalkWho should attend:  Security ...

This Week's Community Digest - Splunk Community Happenings [6.27.22]

Get the latest news and updates from the Splunk Community here! News From Splunk Answers ✍️ Splunk Answers is ...

Reminder! Splunk Love Promo: $25 Visa Gift Card for Your Honest SOAR Review With ...

We recently launched our first Splunk Love Special, and it's gone phenomenally well, so we're doing it again, ...