Splunk Search

REST calling last scheduled search

Jason
Motivator

Is there a way to have REST look up the latest results from a scheduled search and return them, not re-running the search? I'm looking to replicate behavior similar to calling a saved search from the dashboard.

How would you go about doing this?

Tags (4)
1 Solution

Lowell
Super Champion

Looks like you can make a call to:

https://splunkserver:8089/servicesNS/nobody/search/saved/searches/<your_search_name>/history

And from there you get a list of links to previous runs. Each of these links would include the search job id. And from there you should be able to pull the results just as you would any other search job that was dispatched with any other REST call.

Keep in my that you may only have "results" and not "events" depending on how you saved search is setup. (Of course, this is no different than if you had opened a previously run job from the Jobs page as well.)

Does that help?


Side Note: I found this my simply opening a browser to the following URL and doing some quick digging around. If you aren't aware of this, you can find a lot of helpful stuff this way:

https://splunkserver:8089/services

View solution in original post

Lowell
Super Champion

Looks like you can make a call to:

https://splunkserver:8089/servicesNS/nobody/search/saved/searches/<your_search_name>/history

And from there you get a list of links to previous runs. Each of these links would include the search job id. And from there you should be able to pull the results just as you would any other search job that was dispatched with any other REST call.

Keep in my that you may only have "results" and not "events" depending on how you saved search is setup. (Of course, this is no different than if you had opened a previously run job from the Jobs page as well.)

Does that help?


Side Note: I found this my simply opening a browser to the following URL and doing some quick digging around. If you aren't aware of this, you can find a lot of helpful stuff this way:

https://splunkserver:8089/services

Get Updates on the Splunk Community!

Stay Connected: Your Guide to May Tech Talks, Office Hours, and Webinars!

Take a look below to explore our upcoming Community Office Hours, Tech Talks, and Webinars this month. This ...

They're back! Join the SplunkTrust and MVP at .conf24

With our highly anticipated annual conference, .conf, comes the fez-wearers you can trust! The SplunkTrust, as ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had two releases of new security content via the Enterprise ...