Splunk Search

How to update Search Command by JS

cuongnguyen112
Engager

Hello ,
I am using splunk WebFramework to develop, and i got an problem with update splunk search Command by JS

Current Status :
i have seperate SearchManager and Search Command of that like below :

var searchCommand = "index IN (*) | sort -_time"

var searchManager = new SearchManager({
"id": "search",
"search": searchCommand,
"status_buckets": 0,
"cancelOnUnload": true,
"app": utils.getCurrentApp(),
"auto_cancel": 90,
"preview": true,
"earliest_time":"-240h@h",
"latest_time":"now" ,
"runWhenTimeIsUndefined": false
}, {
tokens: true,
tokenNamespace: "submitted"
});

now i need an button to trigger an event that update the searchCommand and re-search.
Is there anyway for me to do that ?

Tags (3)
0 Karma
1 Solution

kamlesh_vaghela
SplunkTrust
SplunkTrust

@cuongnguyen112
Can you please try below javascript code?

searchManager.settings.set("search",UpdatedSearchCommand  )
searchManager.startSearch();

View solution in original post

0 Karma

kamlesh_vaghela
SplunkTrust
SplunkTrust

@cuongnguyen112
Can you please try below javascript code?

searchManager.settings.set("search",UpdatedSearchCommand  )
searchManager.startSearch();
0 Karma

cuongnguyen112
Engager

look like i missing the "quote" over there :D, thank you so much kamlesh

0 Karma

kamlesh_vaghela
SplunkTrust
SplunkTrust

🙂 Glad to help you.

0 Karma
Get Updates on the Splunk Community!

Threat Hunting Unlocked: How to Uplevel Your Threat Hunting With the PEAK Framework ...

WATCH NOWAs AI starts tackling low level alerts, it's more critical than ever to uplevel your threat hunting ...

Splunk APM: New Product Features + Community Office Hours Recap!

Howdy Splunk Community! Over the past few months, we’ve had a lot going on in the world of Splunk Application ...

Index This | Forward, I’m heavy; backward, I’m not. What am I?

April 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...