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
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Network to App: Observability Unlocked [May & June Series]

In today’s digital landscape, your environment is no longer confined to the data center. It spans complex ...

SPL2 Deep Dives, AppDynamics Integrations, SAML Made Simple and Much More on Splunk ...

Splunk Lantern is Splunk’s customer success center that provides practical guidance from Splunk experts on key ...

[Puzzles] Solve, Learn, Repeat: Matching cron expressions

This puzzle (first published here) is based on matching timestamps to cron expressions.All the timestamps ...