Splunk Search

How to run a search from rest search?

aohls
Contributor

I am doing some analysis on our existing searches. What I would like to do is run the saved search when I get the result from a rest search. Right now I have the following, which was working at one point but not sure why it isn't now.

 

 

|rest /servicesns/-/-/saved/searches | where title = "test" | fields search | map search="|makeresult | map search="$search$""

 

 

I have used this before and it was working but some reason now it is not but I can't tell why. Right now I am just running it in a search not in a dashboard. 

Labels (1)
Tags (3)
0 Karma

woodcock
Esteemed Legend

Your search makes no sense to be but it had 2 typos:  Here is the repaired/functional fix:
|rest /servicesNS/-/-/saved/searches | where title = "test" | fields search | map search="|makeresults | map search="$search$""

Now, if you have problems running it in a dahsboard it is because the "$search$ should be "$$search$$" in a dashboard.

0 Karma

yeahnah
Motivator

Hi @aohls 

As it's a saved search already so you are probably better simply loading and running the saved search instead of using the search contents in the map command.  Depending on the complexity of the SPL, using search may just cause issue.

So something like this...

| rest splunk_server=local /servicesNS/-/-/saved/searches
| fields title search
| where title = "test"
| map search="| savedsearch \"$title$\""

 
Hope it helps

0 Karma
Get Updates on the Splunk Community!

Webinar Recap | Revolutionizing IT Operations: The Transformative Power of AI and ML ...

The Transformative Power of AI and ML in Enhancing Observability   In the realm of IT operations, the ...

.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 ...