Getting Data In

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

cdhippen
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:
            try:d
                job = self.service.jobs.(create|results|any jobs./job. call)(query, **kwargs_normalsearch)
                flag = False
            except binding.HTTPError:
                    print('Splunk 504 Error'
                pass
            pass

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!

Troubleshooting the OpenTelemetry Collector

  In this tech talk, you’ll learn how to troubleshoot the OpenTelemetry collector - from checking the ...

Adoption of Infrastructure Monitoring at Splunk

  Splunk's Growth Engineering team showcases one of their first Splunk product adoption-Splunk Infrastructure ...

Modern way of developing distributed application using OTel

Recently, I had the opportunity to work on a complex microservice using Spring boot and Quarkus to develop a ...