Getting Data In

REST API oneshot blocking saved search

leecaf
Explorer

EDIT:
I've gotten some help from Splunk support team and now can get oneshot blocking calls working using the url below:

https://localhost:8089/services/search/jobs?exec_mode=oneshot&output_mode=json&search="search index=_internal | head 10"

however it is unclear to me how I would invoke a oneshot REST call to a saved service. I'm guessing it would look something like the url below but haven't had any success after playign with a few combinations usually a '404 not found':

https://localhost:8089/saved/searches/{name}?exec_mode=oneshot&output_mode=json

can someone help please?

The eventual goal is to be able to import data from splunk into Excel much like how a CSV would be imported.

Tags (2)
0 Karma

Flynt
Splunk Employee
Splunk Employee

What about calling the saved search via the search command itself from the CLI? IE

curl -k -u admin:changeme -d 'search="savedsearch \"Errors in the last 24 hours\""' -d "output_mode=json" -d "exec_mode=oneshot" https://localhost:8089/servicesNS/admin/search/search/jobs/export
0 Karma

dart
Splunk Employee
Splunk Employee

You might find the OData for Splunk app to be a better option.

However, to answer your question, it's hard to see from the data you have supplied. It looks like you have "search=index=_internal |head 5", where you would want search index=_internal | head 5 as the specific error message is saying it's missing a search command (i.e. search) before a quote mark.

0 Karma

leecaf
Explorer

I've tried OData many thanks to Neeraj Luthra. but I'm what I'm trying to do probably doesn't require OData. The problem I'm facing is while OData works nicely out of the box, excel parses the XML it generates in a very verbose manner giving me much more data than I need. I'd rather not have to debug that side of things if Splunk REST API will do the trick for me.

0 Karma

leecaf
Explorer

Thanks, emailed dev for OData.
corrected typo in my original post but still getting same error

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!

Level Up Your .conf25: Splunk Arcade Comes to Boston

With .conf25 right around the corner in Boston, there’s a lot to look forward to — inspiring keynotes, ...

Manual Instrumentation with Splunk Observability Cloud: How to Instrument Frontend ...

Although it might seem daunting, as we’ve seen in this series, manual instrumentation can be straightforward ...

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

Ready to make your IT operations smarter and more efficient? Discover how to automate Splunk alerts with Red ...