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!

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...