Splunk Search

search/jobs/sid/results

justaj
Explorer

Hi,

I'm creating a search via search/jobs. I am then getting the status of the search via search/jobs/sid. Once I see a status of isDone = true then I call search/jobs/sid/results. Nothing is returned.

If I view the sid via the splunk gui I see results so I know it's getting properly created.
For the final get call I am sending: search/jobs/sid/results --get -d output_mode=json

Any suggestions?

Tags (1)
0 Karma

whrg
Motivator

Hello @justaj,

I cannot tell why your final call does not return anything.

However, depending on your use case, you could simplify the whole process. Instead of running multiple API calls (creating the search, querying whether the search has finished, fetching the results), you can also run just one API call. Check out this thread:

How to use the REST API to just run a search and stream the results back?

0 Karma

justaj
Explorer

I found that post a few days ago but it would most likely have the same issue. They are also including the index as a search parameter. I'll try it but it's most likely not going to work

0 Karma

whrg
Motivator

Perhaps it has to do with permissions on knowledge objects such as field extractions, macros, etc. Are you specifying a specific namespace?

If not, specify a namespace like this:

https://yoursplunkserver:8089/servicesNS/YOUR_USERNAME/YOURAPP/search/jobs/.

If you call the API without specifying a namespace, then I believe all knowledge objects must be shared globally.

0 Karma

justaj
Explorer

I just figured out it was a permissions issue. I found this article: https://answers.splunk.com/answers/389557/why-is-our-custom-admin-role-unable-to-search-inte.html

and it turns out the account hadn't been granted rights to everything. Thanks everyone

justaj
Explorer

I found that the issue was specific to a search parameter I had added. For whatever reason when I include 'index' as part of my search no results are returned via curl. I have different environments so I have to pass in 'index=develop'. The same thing works in the Splunk GUI however. If i remove it I get results however I get far too many without the filter.

I did try adding --data-urlencode prior to 'search' but that didn't return any results either

0 Karma

harsmarvania57
Ultra Champion

Hi,

Have you tried with curl ? Like curl -vk -u <user>:<password> https://<SPLUNKSERVER>:<SPLUNK_MGMT_PORT>/services/search/jobs/<SID>/results?output_mode=json

0 Karma
Get Updates on the Splunk Community!

SOC4Kafka - New Kafka Connector Powered by OpenTelemetry

The new SOC4Kafka connector, built on OpenTelemetry, enables the collection of Kafka messages and forwards ...

Your Voice Matters! Help Us Shape the New Splunk Lantern Experience

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Building Momentum: Splunk Developer Program at .conf25

At Splunk, developers are at the heart of innovation. That’s why this year at .conf25, we officially launched ...