Getting Data In

Possible to retrieve all results of a completed search (by search id) using the REST api?

jsinnott_
Explorer

I'm hoping someone can prove me wrong...

It looks to me as though it is not possible to retrieve all results of a completed search via the REST api.

The REST api does support streaming the entire result of a search initiated via that api request:

curl -k -u me:mypass https://myhost:8089/services/search/jobs/export --data-urlencode search='my SPL here' -d output_mode=csv -d earliest_time='-2d@d' -d latest_time='-1d@d' -o my-output.csv

(see an excellent post here: https://www.splunk.com/blog/2013/09/15/exporting-large-results-sets-to-csv.html)

...and the REST api does support retrieving results one page at a time (where the size of a page is limited to a value in limits.conf-- default 50000:

curl -k -u  me:mypass https://myhost:8089/services/search/jobs/1509659457.2999/results -d output_mode=csv -d count=50000 -d offset=0 -o my-output.csv

But to my knowledge, there's no way to retrieve the entire result of a completed search (i.e. by search id) if the size of that result is larger than the page size limit (default 50000).

(note that using the "one page at a time" api in a loop is not desirable because that api appears to have O(n^2) performance-- the first page is nice and fast but the 300th page takes a couple of minutes)

Am I wrong (please!)? Am I crazy (please no!)?

0 Karma

jkat54
SplunkTrust
SplunkTrust

Have you tried count=0?

0 Karma

jsinnott_
Explorer

Thanks for this. I have tried this-- count=0 means, I believe, "give me everything or the limit in limits.conf, whichever is smaller". So I don't think that's the solution.

0 Karma

jkat54
SplunkTrust
SplunkTrust

The rest documentation says it gives an unlimited number. If that doesn’t work, not sure how to solve without modifying limits.conf. Think though, you can export an unlimited number of results to csv from the UI, and the UI is just a wrapper on top of the API... so it can be done.

0 Karma

jsinnott_
Explorer

Thanks for this. Agree with your reading of the doc but experience shows (unless I'm, as I wonder above, crazy) a different behavior.

0 Karma

jkat54
SplunkTrust
SplunkTrust

You can always install a tool like fiddler, start the capture, export an unlimited number via the UI and see the exact rest call that is made by the UI

0 Karma

jsinnott_
Explorer

Thanks for this as well... I'll pursue this although I'm a bit skeptical: Use of fiddler or wireshark to discern api calls is only useful if you have a scenario that produces the desired outcome-- in my case that fetches the entire result set. I don't have any such scenario to apply fiddler/wireshark to... Again thanks for your answer-- am I missing something about your suggestion?

0 Karma

jkat54
SplunkTrust
SplunkTrust

You log into splunk web with fiddler running, go to search,
Run your search,
Click on export, select csv, select unlimited, press ok

0 Karma
Get Updates on the Splunk Community!

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...

What's new in Splunk Cloud Platform 9.1.2312?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.1.2312! Analysts can ...