Splunk Search

REST API

balcv
Contributor

I'm trying to work out how I execute a saved search / report using the REST API.  I have created the token and have all the correct permissions.  An "inline" search in the curl command works and returns the required search results, however I have not been able to successfully get a saved search / report to run.

I know that my saved searches reside in $SPLUNK_Home/etc/users/[user]/[app]/local/savedsearches.conf and I can see the required search of "LV - WiFi Users" in the .conf file.  My problem is how to reference that in the curl api call.

I'm executing:

curl -s -k -H "Authorization: Bearer [key]" "https://[splunk_host]:8089/users/[user]/[app]/local/?output_mode=csv" --data-urlencode search="savedsearch \"LV - WiFi Users\""

and results in "The requested URL was not found on this server." error.

Does anyone have any hints on how I can execute the "LV - WiFi Users"  saved search using a curl API call?

Thanks

Labels (1)
0 Karma

bowesmana
SplunkTrust
SplunkTrust

Take a look at the REST API docs for saved searches

https://help.splunk.com/en/splunk-cloud-platform/rest-api-reference/10.1.2507/search-endpoints/searc...

https://<host>:<mPort>/services/saved/searches/{name}/dispatch

 

PickleRick
SplunkTrust
SplunkTrust

But this returns a sid which has to be queried for completion and you have to fetch results, paginate and so on.

You can use the /services/search/v2/jobs/export endpoint to spawn search and stream the results with a "| savedsearch ..." search. But you might want to use the namespace parameter for the call to set proper... well, namespace 🙂

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!

Kick the Tires Before You Commit: A Hands-On Tour of the Splunk Observability Cloud ...

Evaluating an enterprise observability platform usually goes like this: fill out a form, get a free trial with ...

Deep insights, no barriers: Splunk Observability Cloud Free Edition

As software delivery cycles continue to accelerate, observability shouldn’t be a luxury — it should be a ...

Monitoring AI Agents with Splunk Observability Cloud

Let’s say I’m running a travel planning AI app in production. A user asks for three concise hotel options in ...