Dashboards & Visualizations

Run search in a dashboard if a token has a value in it

jhmoen
New Member

I have a dashboard with textbox used for a search. I would think this is simple but don't see any examples of this out there. I only want to run the dashboard query if the token (textbox) has a value in it. If it does, then run the query, which does work on its own. But if not, then don't run it.

|eval result = if(isnull($LotNumber$),"", sourcetype=xyx |search $LotNumber$) | table result
0 Karma

cmerriman
Super Champion

is your textbox input (token) in your query? The search shouldn't run if it is waiting for a token. the panel would say "Waiting for Input" or something like that until a token was submitted via textbox. In your search, you would just need something like field=$LotNumber|s$

0 Karma

jhmoen
New Member

It is in my query. I simply want:
sourcetype=xyz |search $LotNumber$
This works, but when the page first loads, I get all the results from sourcetype=xyz. I basically want it to wait for the input, then do the search. Likewise, once one is searched, if you were to clear out the textbox and click submit, you would get nothing again (like page load)

0 Karma

javanzato
New Member

Just in case you never figured this out - you should edit the source so that instead of

<search>
.....

it should be

<search depends="$yourtoken$">
....
0 Karma
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 ...