Splunk Search

Why am I getting "splunklb.binding.HTTPError Unknown sid" using the Splunk Python SDK to run a large search?

EricLloyd79
Builder

I am using Splunk Python API to run a large search of about 144343 events and I keep getting an error that I cannot overcome. Oddly, when I run this same search and reduce the number of events to below 130000, it does not produce this error, but produces results correctly. Below is a copy of the Traceback... I have to run this search with this number of events, so reducing the number of events and the time period is not possible. It's already down to 24 hours which is the minimum.
Thanks for any help.

 File "/xxx/functions.py", line 123, in collect_stats
    result_stream = job.results(count=0)
  File "/xxx/splunklib/client.py", line 2750, in results
    return self.get("results", **query_params).body
  File "/xxx/splunklib/client.py", line 981, in get
    return super(Entity, self).get(path_segment, owner=owner, app=app, sharing=sharing, **query)
  File "/xxx/splunklib/client.py", line 738, in get
    **query)
  File "/xxx/splunklib/binding.py", line 286, in wrapper
    return request_fun(self, *args, **kwargs)
  File "/xxx/splunklib/binding.py", line 68, in new_f
    val = f(*args, **kwargs)
  File "/xxx/splunklib/binding.py", line 660, in get
    response = self.http.get(path, self._auth_headers, **query)
  File "/xxx/splunklib/binding.py", line 1150, in get
    return self.request(url, { 'method': "GET", 'headers': headers })
  File "/xxx/splunklib/binding.py", line 1205, in request
    raise HTTPError(response)
splunklib.binding.HTTPError: HTTP 404 Not Found -- Unknown sid.
0 Karma

EricLloyd79
Builder

Update to this question... I discovered the problem was that I was printing the results to the console for debugging and the actual search finished much sooner than the printing finished and by the time the printing was done, the job had expired, I guess. Once I ran the job and the parsing into proper data structures afterward, it worked fine. I resolved the need for a debug printing by running the job a second time after the debug printing was done .. not the most efficient solution. Any other possible solutions would be welcome.

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Take Action Automatically on Splunk Alerts with Red Hat Ansible Automation Platform

 Are you ready to revolutionize your IT operations? As digital transformation accelerates, the demand for ...

Calling All Security Pros: Ready to Race Through Boston?

Hey Splunkers, .conf25 is heading to Boston and we’re kicking things off with something bold, competitive, and ...

Beyond Detection: How Splunk and Cisco Integrated Security Platforms Transform ...

Financial services organizations face an impossible equation: maintain 99.9% uptime for mission-critical ...